Software and s/w Development

Dec 14, 2013 (7 years and 7 months ago)

251 views

ITEC
213

Structured Programming

Eastern Mediterranean University

School of Computing and Technology

Information Technology / Compute
r

Programming

Lab

#1

2010
-

2011
Spring

Semester

Instructors: Cantas Ozerek

Research Assistant: Laika Karsili

Task 1: Complete the following program.

Desired Output:

(a)

Write the function definition of incrementby2

according

to the following main

#include <stdio.h>

void incrementby2(int *);

int main()

{

int num1=10,num2=20,num3;

printf("Before incerement

%d ", num1);

incrementby2(&num1);

printf("After increment %d
\
n", num1) ;

}

/*Write the function definition of incrementby2 below*/

(b)

Modify the function incrementby2 according to the following main

#include <stdio.h>

/*write the function prototype

here*/

int main()

{

int num1=10,num2=20,num3;

printf("Before incerement %d, ", num1);

printf("After increment %d
\
n",incrementby2(&num1)) ;

}

/*write the function definition here */

Task 2 : Complete the following program according to the followi
ng specification

Encrypt function increases each character of the argument by 3.

Decrypt function decreases each character of the argument by 3.

Hint: You can use
strlen

to find the length of a string or you can check for end of string character ‘
\
0’.

Desired Output:

#include <stdio.h>

#include <string.h>

/*Declare function prototypes here*/

void main()

{

char passwd[6];

scanf("%s",passwd);

printf("You have entered %s
\
n",passwd);

encrypt(passwd);

\
n",passwd);

decrypt(passwd);

\
n",passwd);

}

/*Write the code for encrypt function here*/

/*Write the code for decrypt function here*/

Task 3 : Use dynamic memory
allocation to declare an array of real numbers to enter salaries
of N employees. The value of N will be entered by the user.

Enter the data from keyboard.

List all salaries on screen in reverse of data entry

Desired Output: