Record of c Programming
Record of c Programming
AIM
Write a C program to print your name
ALGORITHM
STEP 1: START
STEP 3: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("angel");
getch();
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to print your address
ALGORITHM
STEP 1: START
STEP 3: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("palliparambil(h),bhavanaroad,thomaspuram,mara
du");
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
SUM OF 2 NUMBERS
ALGORITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20,sum;
sum=a+b;
clrscr();
printf("sum=%d",sum);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AREA OF RECTANGLE
AIM
Write a C program to find the area of rectangle
ALGORITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int l=10,b=5,A;
A=l*b;
clrscr();
printf("area=%d",A);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AREA OF SQUARE
ALGORITHM
STEP 1: START
STEP 2: READ a= 5
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,A;
A=a*a;
clrscr();
printf("area=%d",A);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
POSITIVE OR NEGATIVE
NUMBER
AIM
Write a C program to check whether a number is
positive or negative
ALGORITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("ENTER A NUMBER:");
scanf("%d",&a);
if(a>0)
{
printf("positive number");
}
else
{
printf("negative number");
}
getch();
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
LARGEST OF TWO NUMBERS
AIM
Write a C program to find largest of two numbers
ALOGRITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("ENTER FIRST NUMBER:");
scanf("%d",&a);
printf("ENTER SECOND NUMBER:");
scanf("%d",&b);
if(a>b)
{
printf("%d is larger ",a);
}
else
{
printf("%d is larger",b);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to check a number is odd or even
ALGORITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("ENTER A NUMBER");
scanf("%d",&a);
if(a%2==0)
{
printf("%d is a even no",a);
}
else
{
printf("%d is a odd no",a);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
GRADE OF MARKS
AIM
Write a C program to print the grade of marks obtained
ALGORITHM
STEP 1: START
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("ENTER YOUR SCORE:");
scanf("%d",& a);
if(a>90)
{
printf("A+");
}
else if(a>80)
{
printf("A");
}
else if(a>70)
{
printf("B+");
}
else if(a>60)
{
printf("B");
}
else if(a>50)
{
printf("C+");
}
else if(a>40)
{
printf("C");
}
else if(a>30)
{
printf("D+");
}
else if(a>20)
{
printf("D grade just pass");
}
else
{
printf("failed");
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
NUMBER DIVISIBLE BY 5
AIM
Write a C program to check whether a number is
divisible by 5
ALGORITHM
STEP 1: START
STEP 5: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("ENTER A NUMBER:");
scanf("%d",&a);
if(a%5==0)
{
printf("%d is divisible by 5",a);
}
else
{
printf("%d is not divisible by 5",a);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
ALGORITHM
STEP 1: START
STEP 2: READ a
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("ENTER A NO: BETWEEN 1 TO 7");
scanf("%d",&a);
switch(a)
{
case 1:printf("sunday");
break;
case 2:printf("monday");
break;
case 3:printf("tuesday");
break;
case 4:printf("wednesday");
break;
case 5:printf("thursday");
break;
case 6:printf("friday");
break;
case 7:printf("saturday");
break;
default:printf("enter a vaild no.");
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
ARITHMETIC OPERATIONS
USING SWITCH STATEMENT
AIM
Write a C program to perform all arithmetic operations
using switch statement
ALOGRITHM
STEP 1: START
STEP 8: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,choice;
clrscr();
printf("enter two numbers");
sc,anf("%d %d,",& a,& b);
printf("enter your choice:\n 1.addition \n
2.substraction \n 3.multiplication \n 4.division \
nplease enter your choice");
scanf("%d",& choice);
switch(choice)
{
case 1:{
int sum=a+b;
printf("Sum= %d",sum);
break;
}
case 2:{
int c=a-b;
printf("%d - %d =%d",a,b,c);
break;
}
case 3:{
int d=a*b;
printf("%d",d);
break;
}
case 4:{
int e=a/b;
printf("%d",e);
break;
}
default:printf("enter a valid choice");
}
getch();
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to print your name 10 times using
while loop
ALGORITHM
STEP 1: START
STEP 4: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a=0,i=1;
clrscr();
while(a<10)
{
printf("\n angel");
a=a+i;
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
PRINT 1 TO 10 USING
WHILE LOOP
AIM
Write a C program to print 1 to 10 using while loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
#include<stdio.h>
#include<conio.h>
void main()
{
int a=0;
clrscr();
printf("while loop");
while(a<10)
{
a=a+1;
printf("\n%d",a);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
PRINT WELCOME 10 TIMES
USING DO-WHILE
AIM
Write a C program to print welcome 10 times using do
while loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
printf("do-while loop\n");
do
{
printf("\nWELCOME");
i++;
}while(i<=10);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
PRINT 1 TO 10 USING
DO-WHILE LOOP
AIM
Write a C program to print 1 to 10 using do while loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1,i=1;
clrscr();
printf("do-while loop");
do
{
printf("\n%d",a);
a=a+i;
}while(a<=10);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to print welcome 10 times using for
loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("forlooping\n");
for(i=1;i<=10;i++)
{
printf("\nwelcome");
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
PRINT 1 TO 10 USING
FOR LOOP
AIM
Write a C program to print 1 to 10 using for loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("forloop\n");
for(i=1;i<=10;i++)
{
printf("\n%d",i);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AREA OF SQUARE AND
RECTANGLE
(SWITCH STATEMENT)
AIM
Write a C program to find area of square and rectangle
using switch statement
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,l,b,choice;
clrscr();
printf("switch statement\n");
printf("\nEnter your choice \n1.Area of square \
n2.Area of rectangle");
scanf("%d",&choice);
switch(choice)
{
case 1:{ printf("\nEnter a number:");
scanf("%d",&a);
printf("Area=%d",a*a);
break;
}
case 2:{ printf("\nEnter two numbers:");
scanf("%d%d",&l,&b);
printf("Area=%d",l*b);
break;
}
default:printf("Enter a valid choice");
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to find sum of digits of a number
using while loop
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a,i,sum=0;
clrscr();
printf("sum of digits using whileloop\n");
printf("enter a number: ");
scanf("%d" ,&a);
while(a>0)
{
i=a%10;
sum=sum+i;
a=a/10;
}
printf("SUM = %d",sum);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to accept and print your name
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20];
clrscr();
printf("enter your name:");
scanf("%s",a);
printf(“NAME:%s”,a);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
AIM
Write a C program to read and display a single
character
ALGORITHM
STEP 1: START
STEP 2:
STEP 3:
STEP 4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
STEP 9:
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char a;
clrscr();
printf("enter a character:");
scanf("%c",&a);
printf("character:%c",a);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
REPORT CARD
AIM
Write a C program to read students details
roll.no,name,course and marks of 5 subjects.Prepare a
students report card.
ALGORITHM
STEP 1: START
name,couse,roll.no,sub1,sub2,sub3,sub4,sub5,t,p
STEP 5: TOTAL,t=sub1+,sub2+sub3+sub4+sub5
STEP 6: PRINT t
STEP 8: PRINT p
STEP 9: STEP 3: if p>90 THEN PRINT “A” GOTO STEP 12
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char name[20],course[20];
int roll_no;
int P,t,sub1,sub2,sub3,sub4,sub5;
clrscr();
printf(" ENTER YOUR DETAILS");
printf("\n\nenter your name:");
scanf("%s",name);
printf("enter your roll.no:");
scanf("%d",&roll_no);
printf("enter your course:");
scanf("%s",course);
printf("\n\n ENTER YOUR MARK \n");
printf("\n Mark of ENGLISH:");
scanf("%d",&sub1);
printf(" Mark of CYBER:");
scanf("%d",&sub2);
printf(" Mark of C:");
scanf("%d",&sub3);
printf(" Mark of DIGITAL FUNTAMENTALS:");
scanf("%d",&sub4);
printf(" Mark of MATHS:");
scanf("%d",&sub5);
printf("\n\n REPORT CARD \n\n" );
printf("NAME:%s\nROLL.NO:%d\nCOURSE:%s\n\n
MARK OBTAINED\n\nENGLISH:%d\nCYBER:%d\nC:%d\nDIGITAL
FUNDAMENTALS:%d\nMATHS:
%d",name,roll_no,course,sub1,sub2,sub3,sub4,sub5);
t=sub1+sub2+sub3+sub4+sub5;
printf("\n\n\nTOTAL:%d",t);
P=t/5;
printf(" Percentage obtained=
%d",P);
if(P>=90)
{
printf("\nGRADE:A");
}
else if(P>=80)
{
printf("\nGRADE:B");
}
else if(P>=70)
{
printf("\nGRADE:C");
}
else if(P>=60)
{
printf("\nGRADE:D");
}
else if(P<35)
{
printf("\nFaIL");
}
else
{
printf("\nJUST PASS");
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
READ & DISPLAY CHARACTER
UNFORMATTED I/O
AIM
Write a C program to read a character and display it
ALGORITHM
STEP 1: START
STEP 4: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char a;
clrscr();
printf(" UNFORMATTED I/O
FUNCTIONS\n\n");
printf("enter a character:");
a=getchar();
printf("character:");
putchar(a);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
ALGORITHM
STEP 1: START
STEP 4: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20];
clrscr();
printf(" Unformatted i/o functions\n\
n");
printf("enter name:");
gets(a);
printf("NAME:");
puts(a);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
MULTIPLICATION TABLE
AIM
Write a C program to print multiplication table of a
number using for loop
ALGORITHM
STEP 1: START
STEP 3: b= a*i
STEP 4: print b
STEP 5: i++
STEP 6: if i<=10
STEP 7: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,i;
clrscr();
printf(" MULTIPLICATION TABLE\n\n");
printf("Enter a number:");
scanf("%d",&a);
for(i=1;i<=10;i++)
{
b=a*i;
printf("\n%d*%d=%d",a,i,b);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
FACTORIAL OF A NUMBER
AIM
Write a C program to find factorial of a number using
for loop
ALGORITHM
STEP 1: START
STEP 3: fact=fact*i
STEP 4: i++
STEP 7: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,fact=1;
clrscr();
printf("enter a number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
fact=fact*i;
}
printf("Factorial=%d",fact);
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified
FACTORS OF A NUMBER
AIM
Write a C program to print factors of a number using for
loop
ALGORITHM
STEP 1: START
STEP 3: if n%i==0
STEP 4: PRINT i
STEP 5: i++
STEP 7: STOP
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
clrscr();
printf("enter a number:");
scanf("%d",&n);
printf("factors of %d:",n);
for(i=1;i<=n;i++)
{
if(n%i==0)
printf(" %d ",i);
}
getch();
}
OUTPUT
RESULT
The program has been successfully executed and the
output is verified