2
EAST WEST UNIVERSITY Department of Electronics & Communications Engineering Objectives: The main objective of this lab experiment to guide you through a series of simple programming problems, using the basic types of constants, variables, and basic arithmetic operations. Exercise 1: #include<stdio.h> main() { printf("Welcome to the Wonderful World of Computing!\n"); } Exercise 2: #include <stdio.h> /* LIBRARY FILE ACCESS*/ void main() { system("COLOR FC"); /* WHITE BACKGROUND WITH RED TEXT */ printf("This is first statement.\n"); printf("\tThis is second statement"); getch (); } Color Codes 0 = Black 1 = Blue 2 = Green 3 = Aqua 4 = Red 5 = Purple 6 = Yellow 7 = White 8 = Gray 9 = Light Blue A = Light Green B = Light Aqua C = Light Red D = Light Purple E = Light Yellow F = Bright White Fall 2014 Semester ETE 105 LAB Experiment 1: Simple Programs in C Name: ID:

Ete105 fall2014 lab_1 (East West University)

Embed Size (px)

DESCRIPTION

East West University ETE lecture for all.

Citation preview

Page 1: Ete105 fall2014 lab_1 (East West University)

EAST WEST UNIVERSITY

Department of Electronics & Communications Engineering

Objectives:

The main objective of this lab experiment to guide you through a series of simple programming

problems, using the basic types of constants, variables, and basic arithmetic operations.

Exercise 1:

#include<stdio.h>

main()

{

printf("Welcome to the Wonderful World of Computing!\n");

}

Exercise 2:

#include <stdio.h> /* LIBRARY FILE ACCESS*/

void main()

{

system("COLOR FC"); /* WHITE BACKGROUND WITH RED TEXT */

printf("This is first statement.\n");

printf("\tThis is second statement");

getch ();

}

Color Codes

0 = Black 1 = Blue 2 = Green 3 = Aqua 4 = Red 5 = Purple 6 = Yellow 7 = White 8 = Gray 9 = Light Blue

A = Light Green B = Light Aqua C = Light Red D = Light Purple E = Light Yellow F = Bright White

Fall 2014 Semester

ETE 105 LAB

Experiment 1: Simple Programs in C

Name: ID:

Page 2: Ete105 fall2014 lab_1 (East West University)

EAST WEST UNIVERSITY

Department of Electronics & Communications Engineering

Exercise 3:

#include <stdio.h>

int main()

{

system("COLOR F2");

printf("Welcome to the color changing application!\n\n");

printf("Press any key to change the background color!\n\n");

getch();

system("COLOR EC");

printf("Now the background color is Light Yellow and Text Color is

light Red\n\n");

printf("Press any key to exit...");

getch();

return 0;

}

Exercise 4: Write a C program that reads in the radius of a circle, calculates its area and

then displays the calculated result.

#include<stdio.h> /*LIBRARY FILE ACCESS*/

int main() /*FUNCTION HEADING*/

{

float radius, area; /*VARIABLE DECLARATIONS*/

printf("Radius=?"); /*OUTPUT STATEMENT (PROMPT)*/

scanf("%f", &radius); /*INPUT STATEMENT*/

area=3.1416*radius*radius; /*ASSIGNMENT STATEMENT*/

printf("Area=%f\n", area); /*OUTPUT STATEMENT*/

return 0;

}

Lab Assignment:

1. Write a program that prints the following texts on the screen:

Hello World

My Name is John Doe

Goodbye World

2. Write a C program that reads in the base and height of a triangle, calculates its area and

then displays the calculated result.