You are on page 1of 77

HOME ABOUT ME CONTACT ME

LEARN PROGRAMMING TECHNOLOGY NEWS GADGETS PROGRAMMING PRODUCTIVITY RESOURCES

Previous Post

101 Programs to build your Programming Logic [using 65

C Programming]
Prashant Chaudhari September 20, 2012 Learn C Programming, Learn Programming

Most college students feel stiff struggle learning programming logic in college days. Below is list 101 C
Programs, which will help you build basic concepts of control structures, conditional statements and so on.
Programs are written for basic to advance logic building. These programs have been personally written by me 8-
9 years back in my graduation days and were quit helpful to me and all my fellow friends. I hope you all too find
them useful. Cheers !
101 PROGRAMS FOR C-PROGRAMMING
Write a program to print a string in C language
#include<stdio.h> AVAILABLE ON ANDROID !!
#include<conio.h>
main()
{
clrscr();
printf("\nKodeGod.com");
getch();
Search
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to accept values of two numbers and print their addition
#include<stdio.h> FIND US ON FACEBOOK
#include<conio.h>
main()
{ Fifth Dimension Techn
int a,b,c; 248 likes
clrscr();
printf("Enter number 1: ");
scanf("%d",&a);
printf("Enter number 2: "); Contact Us
Like Page
scanf("%d",&b);
c=a+b;
printf("Addition is : %d",c); Be the first of your friends to like this
getch();
}

Write a program to accept values of two numbers and print their subtraction

#include<stdio.h>
#include<conio.h>
main()
SUBSCRIBE & FOLLOW
{
int a,b,c;
clrscr();
printf("Enter number 1: ");
Connect on Facebook
158 Fans
scanf("%d",&a);
printf("Enter number 2: ");
scanf("%d",&b); Follow on Twitter
c=a-b; 35 Followers
printf("Subtraction : %d",c);
getch();
} Subscribe to RSS Feed

Write a program to accept values of two numbers and print their multiplication in C language
#include<stdio.h>
#include<conio.h> POPULAR TAGS
main()
{

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
int a,b,c; 101 Programs to build your Programming Logic [using C
clrscr(); Programming]
printf("Enter number 1: "); September 20, 2012 65
scanf("%d",&a);
printf("Enter number 2: "); Write a program to accept three numbers from user and print
scanf("%d",&b); them in ascending and decending order in C language
c=a*b; September 18, 2012 7
printf("Multiplication: %d",c);
getch(); Write a program to print following outputs in C language
} September 18, 2012 7

Write a program to accept values of two numbers and print their division in C language wordpress page template
#include<stdio.h>
wordpress custom page template
#include<conio.h>
main()
wordpress landing page templates
{
float a,b,c; remove side bar on certain pages
clrscr();
printf("Enter number 1: "); set up a wordpress blog
scanf("%f",&a);
printf("Enter number 2: "); wordpress deployment
scanf("%f",&b);
c=a/b; how to upload wordpress

printf("Division is : %f",c);
uploading wordpress to server
getch();
} setting up a wordpress blog Budget 2012

Write a program to print area of a circle. A(circle)= 3.142 * R * R in C language Tax Slabs 2012 Tax Exemptions for 2012

#include<stdio.h> understand income tax slabs Developer tools


#include<conio.h>
Essential Software Tools Quick Development
main()
{
Google Talk Windows Media Player
float AREA,R;
clrscr();
printf("Enter Radius: ");
scanf("%f",&R); ARCHIVES
AREA=3.14*R*R;
printf("Area of the given is : %6.2f",AREA);
June 2013 (1)
getch();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
September 2012 (102)

Write a program to print area of a triangle A(Triangle)= 0.5 * B * H in C language


August 2012 (1)

#include<stdio.h>
#include<conio.h> May 2012 (2)
main()
{ March 2012 (3)
float AREA,B,H;
clrscr();
printf("Enter Base & Height: ");
scanf("%f%f",&B,&H); POPULAR TAGS
AREA=0.5*B*H;
printf("Area of the given is : %6.2f",AREA);
getch(); Budget 2012 Developer tools Essential Software Tools Google
Talk how to upload wordpress Quick Development remove
}
side bar on certain pages setting up a wordpress blog set up a
wordpress blog Tax Exemptions for 2012 Tax Slabs 2012
Write a program to print simple interest SI = (PNR)/100 in C language understand income tax slabs uploading wordpress to server
#include<stdio.h> Windows Media Player wordpress custom page template
#include<conio.h> wordpress deployment wordpress landing page templates
main() wordpress page template
{
float SI,P,N,R;
clrscr();
printf("Enter Radius: ");
scanf("%f%f%f",&P,&N,&R);
SI=(P*N*R)/100;
printf("Area of the given is : %6.2f",SI);
getch();
}

Write a program to accept a number from user and print its square & cube in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,Square,Cube;
clrscr();
printf("Enter Number: ");

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
scanf("%d",&n);
Square=n*n;
Cube=n*n*n;
printf("\nSquare: %d\nCube: %d",Square,Cube);
getch();
}

Write a program to accept two values a & b and interchange their values in C language
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,temp;
clrscr();
printf("Enter Numbers: ");
scanf("%d%d",&a,&b);
printf("\nBefore Swapping..\na=%d,b=%d",a,b);
temp=a;
a=b;
b=temp;
printf("\nAfter Swapping..\na=%d,b=%d",a,b);
getch();
}

Write a program to accept roll no and marks of 3 subjects of a student, Calculate total of 3 subjects and
average in C language
#include<stdio.h>
#include<conio.h>
main()
{
int roll_no,m1,m2,m3,total;
float average;
clrscr();
printf("Enter roll number : ");
scanf("%d",&roll_no);
printf("Enter marks 1 : ");
scanf("%d",&m1);
printf("Enter marks 2 : ");
scanf("%d",&m2);
printf("Enter marks 3 : ");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
scanf("%d",&m3);
total=m1+m2+m3;
average=total/3.0;
printf("\nStudent Roll Number : %d",roll_no);
printf("\nMarks 1 : %d",m1);
printf("\nMarks 2 : %d",m2);
printf("\nMarks 3 : %d",m3);
printf("\nTotal : %d ",total);
printf("\nAverage : %f ",average);
getch();
}

Print following outputs: http:\\www.kodegod.com\new in C language


#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("http:\\\\www.kodegod.com\\learn-programming");
getch();
}

Print the following output in C Language


#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("\n");
printf(" /\\ \n");
printf(" //\\\\ \n");
printf(" ///\\\\\\ \n");
printf("////\\\\\\\\ \n");
printf(" ||| \n");
printf(" ||| \n");
getch();
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to accept two number and print largest among them in C language

#include<stdio.h>

#include<conio.h>

main()

int a,b;

clrscr();

printf("Enter numbers : ");

scanf("%d%d",&a,&b);

if(a>b)

printf("Largest value is.%d",a);

else

printf("Largest value is.%d",b);

getch();

Write a program to accept a number and print if the number is Positive/Negative in C language
#include<stdio.h>
#include<conio.h>

main()
{
int n;
clrscr();
printf("Enter number..");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
scanf("%d",&n);
if(n>0)
printf("Given number is positive");
else if(n<0)
printf("Given number is negative");
else
printf("Number is Zero");
getch();
}

Write a program to accept a number and check if it is >10, <10 or =10 in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("enter number");
scanf("%d",&n);
if(n>10)
printf("Number is greater than 10");
else if(n<10)
printf("Number is lesser than 10");
else
printf("Number is 10");
getch();
}

Write a program to accept a number from user and print if it is even or odd in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number");
scanf("%d",&n);
if(n%2==0)
printf("Number is even");
else
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("Number is odd.");
getch();
}

Write a program to accept a number from user and print if it is divisible by 5 in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number");
scanf("%d",&n);
if(n%5==0)
printf("Number is divisible by 5.");
else
printf("Number is not divisible by 5.");
getch();
}

Write a program to accept a number from user and print if it is multiple of 7 in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number");
scanf("%d",&n);
if(n%7==0)
printf("Number is multiple of 7");
else
printf("Number is not multiple of 7");
getch();
}

Write a program to accept two numbers from user and compare them in C language
#include<stdio.h>
#include<conio.h>

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
main()
{
int a,b;
clrscr();
printf("Enter numbers");
scanf("%d%d",&a,&b);
if(a>b)
printf("a is greater than b");
else if(b>a)
printf("b is greater tha b");
else
printf("a and b are equal");
getch();
}

Write a program to accept three numbers from user and print them in ascending and decending order in
C language
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter numbers");
scanf("%d%d%d",&a,&b,&c);
if((a>=b)&&(a>=c))
{
if(b>=c)
{
printf("\n Descending order : %d %d %d",a,b,c);
printf("\n Ascending order : %d %d %d",c,b,a);
}
else
{
printf("\n Descending order : %d %d %d",a,c,b);
printf("\n Ascending order : %d %d %d",b,c,a);
}
}
else if((b>=a)&&(b>=c))
{
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
if(a>=c)
{
printf("\n Descending order : %d %d %d",b,a,c);

write a program to calculate roots of a quadratic equations in C language x=b^2-4ac


if x=0 -> only one root ,
if x>0 -> roots are distinct (b+x)/2a & (b-x)/2a
if x roots are imaginary

#include<stdio.h>
#include<conio.h>
main()
{
float x,r1,r2,a,b,c;
clrscr();
printf("Enter a,b,c");
scanf("%f%f%f",&a,&b,&c);
x=b*b-4*a*c;
r1=(-b+x)/2*a;
r2=(-b-x)/2*a;
if(x>0)
printf("\nRoots are unequal\n");
else if(x<0)
printf("\nRoots are imaginary\n");
else
printf("\nRoots are same.\n");
printf("R1 = %f",r1);
printf("R2 = %f",r2);
getch();
}

Write a program to accept roll number ,and marks for three subjects, print total marks and average, also
print grade by considering following conditions Avg>=60 Grade A
Avg=50 Grade B
Avg=40 Grade C

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Grade F.

#include<stdio.h>
#include<conio.h>
main()
{
int RollNumber,m1,m2,m3,total;
float avg;
clrscr();
printf("Enter Roll Number : ");
scanf("%d",&RollNumber);
printf("Enter marks for three subjects : ");
scanf("%d%d%d",&m1,&m2,&m3);
total=m1+m2+m3;
avg=total/3.0;
printf("\nTotal is. %d",total);
printf("\nAverage is.. %5.2f %",avg);
if(avg>=60)
printf("\nGrade : A");
else if((avg>=50)&&(avg<60))
printf("\nGrade : B");
else if((avg>=40)&&(avg<50))
printf("\nGrade : C");
else
printf("\nGrade : F");
getch();
}

Write a Program to accept age, gender, and marital status of a driver and print if he/she is insured
considering following conditions If driver is married then he/she is insured, else not
If he/she is not married, if male & age>=30 then insured else not
If he/she is not married, if female & age>=25 then insured else not.

#include<stdio.h>
#include<conio.h>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
main()
{
int age;
char MaritalStatus,Gender;
clrscr();
printf("Enter MaritalStatus, Gender, Age : (e.g. m,f,25) : ");
scanf("%c,%c,%d",&MaritalStatus,&Gender,&age);
if(MaritalStatus==m)
{
printf("Driver is Insured !!!");
}
else if(MaritalStatus==u)
{
if(Gender==m)
{
if(age>=30)
printf("Insured !!!");
else
printf("Not Insured !!!");
}
else if(Gender==f)
{
if(age>=18)
printf("Insured !!!");
else
printf("Not Insured !!!");
}
else

Write a Program to print numbers 1 to n using while loop in C language


#include<stdio.h>
#include<conio.h>
main()
{
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
int i=1,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
while(i<=n)
{
printf("%d\t",i);
i++;
}
getch();
}

Write a Program to print numbers n to 1 using Do While loop in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i=1,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
i=n;
do
{
printf("%d\t",i);
i;
}while(i>=1);
getch();
}

Write a Program to print first n even numbers in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i=2,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
while(i<=n)
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{
printf("%d\t",i);
i=i+2;
}
getch();
}

Write a Program to print first n odd numbers in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i=1,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
while(i<=n)
{
printf("%d\t",i);
i=i+2;
}
getch();
}

Write a Program to accept a number and print the number in reverse order. E.g. if 1324 is the number
then the output will be 4231 in C language
#include<stdio.h>
#include<conio.h>
main()
{
int rem,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
printf("%d",rem);
n=n/10;
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
getch();
}

Write a Program to accept a number and print sum of its digits in C language
#include<stdio.h>
#include<conio.h>
main()
{
int rem,sum=0,n
clrscr();
printf("Enter n : ");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
sum=sum+rem;
n=n/10;
}
printf("Sum of digits.%d",sum);
getch();
}

Write a program to accept a number from user and check it it is Armstrong number or not i.e. 153 = 1^3 +
5^3 + 3^3 = 153 in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i=2,temp,rem,sum=0 ,n;
clrscr();
printf("Enter n : ");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
if(temp==sum)
printf("Armstrong Number");
else
printf("Not an Armstrong Number");
getch();
}

Write a program to print table of a given number n in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=10;i++)
printf("%d X %d = %d\n",n,i,n*i);
getch();
}

Write a program to print sum of given first n numbers in C language


#include<stdio.h>
#include<conio.h>
main()
{
int n,newn,i,sum=0;
clrscr();
printf("enter number : ");
scanf("%d",&n);
printf("Numbers entered.\n");
for(i=1;i<=n;i++)
{
scanf("%d",&newn);
sum=sum+newn;
}
printf("Sum of given n digits is %d",sum);
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to print following outputs in C language ****
****
****
****

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Write a program to print following outputs in C language *


**
***
****

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
clrscr();

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Write a program to print following outputs in C language ****


***
**
*

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=n;i>=1;i)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}

Write a program to print following outputs in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=1;k<i;k++)
{
printf(" ");
}
for(j=i;j<=n;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Write a program to print following outputs in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
scanf("%d",&n);
for(i=n;i>=1;i)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Write a program to print following outputs in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
for(j=2;j<=i;j++)
{
printf("*");
}

printf("\n");
}
getch();
}

Write a program to print following outputs in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=n;i>=1;i)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
for(j=2;j<=i;j++)
{
printf("*");
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("\n");
}
getch();
}

Write a program to print following outputs in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);

for(i=1;i<=n;i++)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
for(j=2;j<=i;j++)
{
printf("*");
}

printf("\n");
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=n-1;i>=1;i)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
for(j=2;j<=i;j++)
{
printf("*");
}

printf("\n");
}
getch();
}

Write a program to print following outputs in C language 1


12
123
1234

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
getch();
}

Write a program to print following outputs in C language 1


22
333
4444

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",i);
printf("\n");
}
getch();
}

Write a program to print following outputs in C language


A
BBB
CCCCC

#include<stdio.h>

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<conio.h>
main()
{
int i,j,k,n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
//ASCII Code for A is 65
for(i=1;i<=n;i++)
{
for(k=1;k<=(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%c",64+i);
}
for(j=2;j<=i;j++)
{
printf("%c",64+i);
}

printf("\n");
}
getch();
}

Write a program to print following outputs in C language


ABCDEEBCBA
ABCD BCBA
ABC CBA
AB BA
AA

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,j,k;
clrscr();
printf("Enter number..");
scanf("%d",&n);
for(i=n-1;i>=0;i)
{
for(j=0;j<=i;j++)
printf("%c",65+j);
for(k=1;k<(n-i);k++)
printf(" ");
for(j=i;j>=0;j)
printf("%c",65+j);
printf("\n");
}
getch();
}

Write a program to print following outputs in C language


1
11
121
1231
12341

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
clrscr();
printf("Enter number");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("1\n");
}
getch();
}

Write a program to accept a number from user and print its factorial in C language Eg: factorial of 5 is:-
5! = 5 * 4 * 3 * 2 * 1=120

#include<stdio.h>
#include<conio.h>
main()
{
int i,fact=1,n;
clrscr();
printf("Enter number");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf("facttorialof the given number is%d",fact);
getch();

Write a program to accept a number from user and print if it is prime or not in C language
#include<conio.h>
#include<process.h>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
main()
{
int i,n;
clrscr();
printf("Enter number");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
printf("Not Prime");
getch();
exit(0);
}
}
printf("Prime ");
getch();
}

Write a program to accept a number and print prime numbers between 2 and n in C language

#include<stdio.h>
#include<conio.h>
#include<process.h>
main()
{
int i,flag=1,n,newn;
clrscr();
printf("Enter number");
scanf("%d",&n);
for(newn=2;newn<=n;newn++)
{
flag=1;
for(i=2;i<=newn/2 ;i++)
{
if(newn%i==0)
{
flag=0;
break;
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
if(flag==1)
printf("%d ",newn);
}
getch();
}

Write a program to accept a number and print fibonacci series upto that level in C language
#include<stdio.h>
#include<conio.h>
main()
{
int pre=1,cur=1,temp,i,n;
clrscr();
printf("Enter number");
scanf("%d",&n);
printf("%d\t%d",pre,cur);
for(i=3;i<=n;i++)
{
temp=cur;
cur=pre+cur;
pre=temp;
printf("\t%d",cur);
}
getch();
}

Write a program to print digits, alphabets in capital and lower case in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=65;i<=90;i++)
printf("%c ",i);

printf("\n\n\n\n");
for(i=97;i<=122;i++)
printf("%c ",i);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("\n\n\n\n");
for(i=48;i<=57;i++)
printf("%c\t",i);

getch();
}

Write a program to accept a number n from user and Add n terms of the series in C language 1/2! + 2/3!
+ 3/4! + 4/5! + 5/6! +

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
float sum=0,fact=1;
clrscr();
printf("Enter number.");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
fact=1;
for(j=1;j<=i+1;j++)
fact=fact*j;
sum=sum+i/fact;
}
printf("Sum of the series.%f",sum);
getch();
}

Write a program to read n numbers (Xi) from the user and print out their average and standard deviation.
Formulae are Average = (Sum of Xi)/n ,
Standard Deviation= Sum of (Xi *Xi)/(n*n)

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,newn,sum_avg=0,sum_sd=0;
float sd,avg;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("Enter numbers");
for(i=1;i<=n;i++)
{
scanf("%d",&newn);
sum_avg=sum_avg+newn;
sum_sd=sum_sd+(newn*newn);
}
avg=sum_avg/(float)n; //Type casting.
sd=sum_sd/(float)(n*n);//Type casting
printf("\nAverage = %f",avg);
printf("\nStandard Deviation = %f",sd);
getch();
}

Write a program to print out ASCII chart on a single screen (all 256 characters from 0 to 255) in a tabular
form. The ASCII code should be followed by the corresponding character in C language

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
for(i=0;i<=255;i++)
printf("%d-%c\t",i,i);
getch();
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to print following output
*******************************
**
*

Write a program to accept a single value interger from user and print that integer in words in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,rem;
clrscr();
printf("Enter number");
scanf("%1d",&n); //%1d to scan single integer
switch(n)
{
case 0 : printf("Zerro ");break;
case 1 : printf("One ");break;
case 2 : printf("Two ");break;
case 3 : printf("Three ");break;
case 4 : printf("Four ");break;
case 5 : printf("Five ");break;
case 6 : printf("Six ");break;
case 7 : printf("Seven ");break;
case 8 : printf("Eigth ");break;
case 9 : printf("Nine ");break;
}
getch();
}

Write a program to print following output


#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
printf("+");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=2;i<=79;i++)
printf("-");
printf("+");
for(i=2;i<=24;i++)
{
printf("|");
for(j=2;j<=79;j++)
printf(" ");
printf("|");
}
printf("+");
for(i=2;i<=79;i++)
printf("-");
printf("+");

getch();
}

Write a program to accept a number from user and print that number in words but in reverse order in C
language E.g. 153 -> THREE FIVE ONE
#include<stdio.h>
#include<conio.h>
main()
{
int n,rem;
clrscr();
printf("Enter number");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
switch(rem)
{
case 0 : printf("Zerro ");break;

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
case 1 : printf("One ");break;
case 2 : printf("Two ");break;
case 3 : printf("Three ");break;
case 4 : printf("Four ");break;
case 5 : printf("Five ");break;
case 6 : printf("Six ");break;
case 7 : printf("Seven ");break;
case 8 : printf("Eigth ");break;
case 9 : printf("Nine ");break;
}
n=n/10;

}
getch();
}

Write a Program to accept two numbers and a operator (+, -, *, / from user and complete that particular
operation only in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,rem,a,b;
char op;
clrscr();
printf("Enter Operator(+,-,*,/)");
scanf("%c",&op);
printf("Enter numbers");
scanf("%d%d",&a,&b);
switch(op)
{
case + : printf("Result : %d ",a+b);break;
case - : printf("Result : %d ",a-b);break;
case * : printf("Result : %d ",a*b);break;
case / : printf("Result : %d ",a/b);break;
default : printf("Invalid operator.");
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
getch();
}

Write a program to accept a number n from user and then accept n array elements from user and reprint
them in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20];
clrscr();
printf("Enter number");
scanf("%d",&n);
printf("Enter array elements :\n" );
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
printf("\nElement %d : %d",i+1,a[i]);
getch();
}

Write a program to accept a number n from user and then accept n array elements from user and reprint
them in reverse order of inputs in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20];
clrscr();
printf("Enter number");
scanf("%d",&n);
printf("Enter array elements :\n" );
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=n-1;i>=0;i)
printf("\nElement %d : %d",i+1,a[i]);
getch();
}

Write a program to accept a number n from user and then accept n array elements from user and print
addition of those n array elements in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20],sum=0;
clrscr();
printf("Enter number");
scanf("%d",&n);
printf("Enter array elements :\n" );
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}

for(i=0;i<n;i++)
sum=sum+a[i];
printf("\nSum of given array elements is : %d",sum);
getch();
}

Write a program to accept a number n from user and print fibbonacci series up to nth level using arrays in
C language
#include<stdio.h>
#include<conio.h>
main()
{
int a[20],n,i;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
a[1]=a[2]=1;

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=3;i<=n;i++)
a[i]=a[i-1]+a[i-2];

for(i=1;i<=n;i++)
printf(" %d",a[i]);

getch();
}

Write a program to accept a number n from user and then accept n array elements from user and print
maximum and minimum array element from that set of array in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20],max,min;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("Enter array elements\n");
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}
max=min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("\nMin : %d",min);
printf("\nMax : %d",max);
getch();
}

Write a program to accept a number n from user and then accept n array elements from user, print

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
positive & Negative numbers separately in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20];
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("Enter array elements\n");
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}

printf("\n\nNegative Elements : \n");


for(i=0;i<n;i++)
if(a[i]<0)
printf("\n%d",a[i]);

printf("\n\nPositive Elements : \n");


for(i=0;i<n;i++)
if(a[i]>0)
printf("\n%d",a[i]);

getch();
}

Write a program to accept a number n from user and then accept n array elements from user, print these
array elements in ascending and descending order in C language
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,a[20],j,max,min,temp;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("Enter array elements\n");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=0;i<n;i++)
{
printf("Enter element %d : ",i+1);
scanf("%d",&a[i]);
}
max=a[0];
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("Ascending order..\n");
for(i=0;i<n;i++)
{
printf(" %d ",a[i]);
}

min=a[0];
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("\nDescending order.\n");
for(i=0;i<n;i++)
{
printf(" %d ",a[i]);
}

getch();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}

Write a program to accept a mXn matrix and reprint it in matrix form in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,n,a[5][5];
clrscr();
printf("Enter order of matrix :\n");
scanf("%d%d",&m,&n);
printf("Enter matrix elements..\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d ",a[i][j]);
printf("\n");
}
getch();
}

Write a program to accept two mXn matrices and add them in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,n,a[5][5],b[5][5],c[5][5];
clrscr();
printf("Enter order of matrix :\n");
scanf("%d%d",&m,&n);
printf("Enter matrix elements of first matrix..\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

printf("Enter matrix elements of second matrix..\n");


open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);

for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];

printf("Resultant matrix ..\n");


for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d ",c[i][j]);
printf("\n");
}
getch();
}

Write a program to accept a mXn matrix and print addition of their array elements in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,n,a[5][5],sum=0;
clrscr();
printf("Enter order of matrix :\n");
scanf("%d%d",&m,&n);
printf("Enter matrix elements..\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

for(i=0;i<m;i++)
for(j=0;j<n;j++)
sum=sum+a[i][j];

printf("\nSum of matrix elements..%d",sum);


getch();
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to accept a nXn matrix and print addition of digonal elements of that matrix in C
language

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,a[5][5],sum=0;
clrscr();
printf("Enter order of matrix :\n");
scanf("%d",&m);
printf("Enter matrix elements..\n");
for(i=0;i<m;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);

for(i=0;i<m;i++)
for(j=0;j<m;j++)
if(i==j)
sum=sum+a[i][j];

printf("\nSum of diagonal elements..%d",sum);


getch();
}

Write a program to accept a N x N matrix and print addition of upper triangular matrix elements in C
language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,a[5][5],sum=0;
clrscr();
printf("Enter order of matrix :\n");
scanf("%d",&m);
printf("Enter matrix elements..\n");
for(i=0;i<m;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=0;i<m;i++)
for(j=0;j<m;j++)
if(i<j)
sum=sum+a[i][j];

printf("\nSum of upper triangular elements..%d",sum);


getch();
}

Write a program to accept a N x N matrix and print addition of lower triangular matrix elements in C
language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,a[5][5],sum=0;
clrscr();
printf("Enter order of matrix :\n");
scanf("%d",&m);
printf("Enter matrix elements..\n");
for(i=0;i<m;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);

for(i=0;i<m;i++)
for(j=0;j<m;j++)
if(i>j)
sum=sum+a[i][j];

printf("\nSum of lower triangular elements..%d",sum);


getch();
}

Write a program to accept two m X n matices and print their addition and multiplication in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,n,k,a[5][5],b[5][5],c[5][5];
clrscr();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("Enter order of matrix :\n");
scanf("%d%d",&m,&n);
printf("Enter matrix elements of first matrix..\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

printf("Enter matrix elements of second matrix..\n");


for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);

for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}

printf("Resultant matrix ..\n");


for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d ",c[i][j]);
printf("\n");
}
getch();
}

Write a program to accept a m X n matrix and print its transpose matrix in C language
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,m,n,a[5][5];
clrscr();
printf("Enter order of matrix :\n");
scanf("%d%d",&m,&n);
printf("Enter matrix elements..\n");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d ",a[j][i]);
printf("\n");
}
getch();
}

Write a program to accept two numbers from user and print its
addition,subtraction,multiplication,division using different functions in C language

#include<stdio.h>
#include<conio.h>

int add(int x,int y)


{
return(x+y);
}

int sub(int x,int y)


{
return(x-y);
}

int mul(int x,int y)


{
return(x*y);
}

int div(int x,int y)


{
return(x/y);
}

main()
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{
int a,b;
clrscr();
printf("Enter numbers : \n");
scanf("%d%d",&a,&b);
printf("\nAddition : %d\n",add(a,b));
printf("\nSubtraction : %d\n",sub(a,b));
printf("\nMultiplication : %d\n",mul(a,b));
printf("\nDivision : %d\n",div(a,b));
getch();
}

Write a program to accept a number from user and print its factorial, check if it prime or not , and print
its fibbonacci series using different functions in C language

#include<stdio.h>
#include<conio.h>

fact(int x)
{
int i,fact=1;
for(i=1;i<=x;i++)
fact=fact*i;
printf("Factorial is : %d",fact);
}

IsPrime(int x)
{
int i;
for(i=2;i<x-1;i++)
{
if(x%i==0)
{
printf("\nNot a Prime Number\n");
return 0;
}
}
printf("\nIt is a Prime number\n");
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
fibbo(int x)
{
int pre=1,cur=1,i,temp;
printf("%d %d",pre,cur);
for(i=3;i<=x;i++)
{
temp=cur;
cur=pre+cur;
pre=temp;
printf(" %d",cur);
}
}
main()
{
int n;
clrscr();
printf("Enter number");
scanf("%d",&n);
fact(n);
IsPrime(n);
fibbo(n);
getch();
}

Write a program to calculate square and cube of a given number in C language

#include<stdio.h>
#include<conio.h>

int square(int x)
{
return(x*x);
}

int qube(int x)
{
return(x*x*x);
}
main()
{
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
int n;
clrscr();
printf("Enter number..");
scanf("%d",&n);
printf("\nSquare : %d\n",square(n));
printf("\nQube : %d\n",qube(n));
qube(n);
getch();
}

Write a program using recursions for fibbonacci series in C language

#include<stdio.h>
#include<conio.h>
#include<process.h>
fibbo(int pre, int cur ,int x)
{ int temp;
if(x==2)
{
getch();
exit(0);
}
temp=cur;
cur=pre+cur;
pre=temp;
printf("%d ",cur);
fibbo(pre,cur,x-1);
}
main()
{
int n,pre=1,cur=1;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("%d %d ",pre,cur);
fibbo(pre,cur,n);
getch();
}

Write a program using reccursions for fibbionacci series factorial in C language


open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<stdio.h>
#include<conio.h>
#include<process.h>

int fact(int n)
{
int f;
if(n==1)
return 1;
else
f=n*fact(n-1);
return f;
}
main()
{
int n;
clrscr();
printf("Enter number : ");
scanf("%d",&n);
printf("\nFactorial is%d\n",fact(n));
getch();
}

Write a program to accept two numbers from user and swap their values using call by reference method
in C language
#include<stdio.h>
#include<conio.h>
#include<process.h>

swap(int *x ,int *y)


{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
main()
{
int a,b;
clrscr();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("Enter numbers : ");
scanf("%d%d",&a,&b);
printf("\nBefore Swapping a = %d, b = %d\n",a,b);
swap(&a,&b);
printf("\nAfter Swapping a = %d, b = %d\n",a,b);
getch();
}

Write a program to accept a string and print the string in reverse order in C language
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char *s1;
clrscr();
printf("Enter string : ");
scanf("%s",s1);
printf("Reverse String : %s",strrev(s1));
getch();
}

Write a program to calculate lenght of a given string in C language


#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char *s1;
clrscr();
printf("Enter string : ");
scanf("%s",s1);
printf("Lenght: %d",strlen(s1));
getch();
}

Write a program to accept a string and print the string in upper case in C language
#include<stdio.h>
#include<conio.h>

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<string.h>
main()
{
char *s1;
clrscr();
printf("Enter string:");
scanf("%s",s1);
printf("String in UPPER CASE : %s",strupr(s1));
getch();
}

Write a program to accept a string and print the string in lower case in C language

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char *s1;
clrscr();
printf("Enter string: ");
scanf("%s",s1);
printf("String in lower case : %s",strlwr(s1));
getch();
}

Write a program to accept a string and print no. of aphlabets, digits, special symbols present in it in C
language
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
main()
{
char *s;
int i,alpha=0,digit=0,symbol=0;
clrscr();
printf("Enter string : ");
scanf("%s",s);
for(i=0;s[i]!=\0 ;i++)

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
if(isalpha(s[i]))
alpha++;
else if(isdigit(s[i]))
digit++;
else
symbol++;

printf("\nAphabets : %d",alpha);
printf("\nDigits : %d",digit);
printf("\nSymbols : %d",symbol);
getch();
}

Write a program to accept two strings and compare them in C language


#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char *s1,*s2;
clrscr();
printf("Enter string 1 : ");
scanf("%s",s1);
printf("Enter string 2 : ");
scanf("%s",s2);

if(strcmp(s1,s2)>0)
printf("\nString 1 is greater..");
else if(strcmp(s1,s2)<0)
printf("\nString 2 is greater..");
else
printf("\nStrings are equal..");

getch();
}

Write a program to accept two strings and concatenate them in C language


#include<stdio.h>
#include<conio.h>
#include<string.h>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
#include<string.h>
main()
{
char *s1,*s2;
clrscr();
printf("Enter string 1 : ");
scanf("%s",s1);
printf("Enter string 2 : ");
scanf("%s",s2);
printf("\nCocatinated string is%s",strcat(s1,s2));
getch();
}

Write a program to accept a string and copy it into another string in C language
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char *s1,*s2;
clrscr();
printf("Enter string 1 : ");
scanf("%s",s1);
strcpy(s2,s1);
printf("\nCopied string is%s",s2);
getch();
}

Write a program to print length of a given string in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,len=0;
char *s;
clrscr();
printf("Enter the string.");
scanf("%s",s);
for(i=0;s[i]!=\0 ;i++)
len++;

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("The lenth of the string is%d",len);
getch();
}

Write a program to copy a string into another string in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i;
char *s1,*s2;
clrscr();
printf("Enter the string 1.");
scanf("%s",s1);
for(i=0;s1[i]!=\0 ;i++)
{
s2[i]=s1[i];
}
s2[i]=\0 ;
printf("The copied string is%s",s2);
getch();
}

Write a program to convert given string to UPPER CASE in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i;
char *s1;
clrscr();
printf("Enter the string 1.");
scanf("%s",s1);

for(i=0;s1[i]!=\0 ;i++)
{
if((s1[i]>=a)&&(s1[i]<=z))
s1[i]=s1[i]-32;
}
printf("Resultant string is%s",s1);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
getch();
}

Write a program to convert givern string to lower case in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i;
char *s1;
clrscr();
printf("Enter the string 1.");
scanf("%s",s1);

for(i=0;s1[i]!=\0 ;i++)
{
if((s1[i]>=A)&&(s1[i]<=Z))
s1[i]=s1[i]+32;
}

printf("Resultant string is%s",s1);


getch();
}

Write a program to concatinate two strings in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,len=0,j;
char *s1,*s2;
clrscr();
printf("Enter the string 1.");
scanf("%s",s1);
printf("Enter the string 2.");
scanf("%s",s2);

for(i=0;s1[i]!=\0 ;i++)
{
len++;
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
len++;
}
j=0;
for(i=len;s2[j]!=\0 ;i++)
{
s1[i]=s2[j];
j++;
}
s1[i]=\0 ;

printf("Resultant string is%s",s1);


getch();
}

Write a program to count no, of alphlabets, digits, special symbols in C language

#include<stdio.h>
#include<conio.h>
main()
{
int i,alpha=0,digit=0,symbol=0;
char *s;
clrscr();
printf("Enter the string 1.");
scanf("%s",s);

for(i=0;s[i]!=\0 ;i++)
{
if(((s[i]>=A)&&(s[i]<=Z))||((s[i]>=a)&&(s[i]<=z)))
alpha++;
else if((s[i]>=0)&&(s[i]<=9))
digit++;
else
symbol++;
}
printf("\nAlphabets : %d",alpha);
printf("\nDigits : %d",digit);
printf("\nSymbols : %d",symbol);
getch();
}

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Write a program to compare two strings in C language
#include<stdio.h>
#include<conio.h>
#include<process.h>
main()
{
int i;
char *s1,*s2;
clrscr();
printf("Enter the string 1.");
scanf("%s",s1);
printf("Enter the string 2.");
scanf("%s",s2);

for(i=0;s1[i]!=\0 ;i++)
{
if(s1[i]!=s2[i])
{
if(s1[i]>s2[i])
printf("\nString 1 is greater");
else
printf("\nString 2 is greater");
getch();
exit(0);
}
}
printf("String are equal.");
getch();
}

Write a program to count all vowels present in the string in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,vowel=0;
char *s;
clrscr();
printf("Enter the string 1.");
scanf("%s",s);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
for(i=0;s[i]!=\0 ;i++)
{
if((s[i]==A)||(s[i]==E)||(s[i]==O)||(s[i]==U)||(s[i]==I)||
(s[i]==a)||(s[i]==e)||(s[i]==o)||(s[i]==u)||(s[i]==i))
vowel++;
}
printf("\nVowels : %d",vowel);
getch();
}

Write a program to reverse the given string in C language


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,len=0;
char *s1,*s2;
clrscr();
printf("Enter the string .");
scanf("%s",s1);
for(i=0;s1[i]!=\0 ;i++)
len++;
j=0;
for(i=len-1;i>=0;i)
{
s2[j]=s1[i];
j++;
}
s2[j]=\0 ;
printf("\nReversed String : %s",s2);
getch();
}

Write a program to check if the given string is palindrome or not E.g. NITIN, LIRIL, MALAYALAM.
#include<stdio.h>
#include<conio.h>
#include<process.h>
main()
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{
int i,j,len=0;
char *s1,*s2;
clrscr();
printf("Enter the string .");
scanf("%s",s1);
for(i=0;s1[i]!=\0 ;i++)
len++;
j=0;
for(i=len-1;i>=0;i)
{
s2[j]=s1[i];
j++;
}
s2[j]=\0 ;
for(i=0;s1[i]!=\0 ;i++)
if(s1[i]!=s2[i])
{
printf("\nNot a palindrome");
getch();
exit(0);
}
printf("Palindrome");
getch();
}

Define a structure Employee having elements emp_id, name,etc. Accept data and reprint it
#include<stdio.h>
#include<conio.h>

struct Employee
{
char name[50];
int emp_id;
long phone_no;

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
};

main()
{
struct Employee e;
clrscr();
printf("Enter name : ");
scanf("%s",&e.name);
printf("Enter emp_id: ");
scanf("%d",&e.emp_id);
printf("Enter Phone Number: ");
scanf("%ld",&e.phone_no);

printf("\n\nEnter name : %s",e.name);


printf("\n\nEnter Emp Id : %d",e.emp_id);
printf("\n\nEnter Phone Number : %ld ",e.phone_no);

getch();
}

Define a structure Student having fields roll_no, name, marks, etc, for 5 students, accept data and reprint

#include<stdio.h>
#include<conio.h>

struct Student
{
char name[50];
int roll_no;
int m1,m2,m3;
};

main()
{ int i;
struct Student s[5];
clrscr();
for(i=0;i<5;i++)
{ printf("\nEnter data for Student %d..\n",i+1);
printf("Enter name : ");
scanf("%s",&s[i].name);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
printf("Enter Roll No. : ");
scanf("%d",&s[i].roll_no);
printf("Enter marks for sub1 : ");
scanf("%d",&s[i].m1);
printf("Enter marks for sub2 : ");
scanf("%d",&s[i].m2);
printf("Enter marks for sub3 : ");
scanf("%d",&s[i].m3);
}

for(i=0;i<5;i++)
{ printf("\nStudent %d\n",i+1);
printf("Name : %s\n",s[i].name);
printf("Roll No.: %d\n",s[i].roll_no);
printf("Sub1 : %d\n",s[i].m1);
printf("Sub2 : %d\n",s[i].m2);
printf("Sub3 : %d\n",s[i].m3);
}

getch();
}

Define a structure Employee having elements emp_id, name, DOB, DOJ etc. Accept data and reprint it.
(use structure within structure)
#include<stdio.h>
#include<conio.h>

struct Date
{
int mm,dd,yy;
};

struct Employee
{
char name[50];
int emp_id;
struct Date DOB,DOJ;
};

main()
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{ int i;
struct Employee e;
clrscr();
printf("\nEnter name : ");
scanf("%s",&e.name);
printf("\nEnter emp_id. : ");
scanf("%d",&e.emp_id);
printf("\nEnter Date of Joining\n ");
printf("(dd-mm-yy) : ");
scanf("%d-%d-%d", &e.DOJ.dd,&e.DOJ.mm,&e.DOJ.yy);
printf("\nEnter Date of birth\n ");
printf("(dd-mm-yy) : ");
scanf("%d-%d-%d", &e.DOB.dd,&e.DOB.mm,&e.DOB.yy);

printf("\nName : %s",e.name);
printf("\nEmployee ID : %d",e.emp_id);
printf("\nEnter DOJ : %d-%d-%d", e.DOJ.dd,e.DOJ.mm,e.DOJ.yy);
printf("\nEnter DOB : %d-%d-%d", e.DOB.dd,e.DOB.mm,e.DOB.yy);

getch();
}

More

By Prashant Chaudhari

About the Author


Twitter - Facebook

65 Comments
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
shakeel January 5, 2014 at 12:57 am - Reply

thanks a lot for making this kind post to help the programmers with solution .. lots of
respects

Prashant Chaudhari January 29, 2014 at 4:29 pm - Reply

Glad to know that this is helping you share this with all your friends.

Saswat March 15, 2014 at 11:34 pm - Reply

I would have loved to have an ebook so that I could print them and read them when I got
time.
Anyways tjis a great site for beginners to start develop good logic for C prog..

Prashant Chaudhari March 16, 2014 at 10:33 pm - Reply

Hi Saswat, i am happy to know that this is helping you


Share this with all your friends.

sachin May 20, 2014 at 4:38 pm - Reply

really helpfull for beginner!!!!!!thanks.

Prashant Chaudhari May 24, 2014 at 11:03 am - Reply

i am happy to know that this is helping you


Share this with all your friends.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
aditya June 28, 2014 at 4:11 am - Reply

thank u so much for providing us such an easy way to learn basics of programming
really thanks a lot..

Prashant Chaudhari June 28, 2014 at 7:23 am - Reply

Hi Aditya, I am glad to none that, these programs are helping you, share
these with your friends as well.

aditya June 28, 2014 at 4:14 am - Reply

thank u so much for providing us such an easy way to learn basics of programming
thanks a lot..

rohit sharma July 15, 2014 at 11:02 pm - Reply

thanks for this ,m so great full to u

Prashant Chaudhari July 16, 2014 at 12:20 am - Reply

Glad to know that, this blog is helping you. Share this link with your friends
and help them.

HARSH July 18, 2014 at 6:30 pm - Reply

Wonderful Post and very helpful for beginner like me, Thanks

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Prashant Chaudhari July 20, 2014 at 12:39 am - Reply

Hey Harsh, I am glad to know that these programs are helping you. Hate
this with friends and lets help them as well.

ganesh nalla July 22, 2014 at 10:22 pm - Reply

Hey bro,the work done by you is greatly appreciableyou have helped us to improve our
logic through this great work

Prashant Chaudhari July 22, 2014 at 11:09 pm - Reply

Hey Ganesh, its so good to hear that these programs are helpful. Share
these with your friends. Thank you

sugan July 26, 2014 at 12:42 am - Reply

Its very useful for develop a C programNow i am cleared in c logics.. thank you..

Prashant Chaudhari July 26, 2014 at 7:16 am - Reply

Hi Sugan, I am so happy to know that these programs have helped you.


Share these links with your friends and help them as well.

swagata August 18, 2014 at 10:58 pm - Reply

i want to know about atoi logic

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Prashant Chaudhari August 19, 2014 at 12:10 am - Reply

The C library function int atoi(const char *str) converts the string argument
str to an integer (type int).
the declaration is as below
int atoi(const char *str)

swagata August 19, 2014 at 8:56 pm - Reply

thnxxx

Nitin tiwari August 22, 2014 at 7:15 pm - Reply

Very use full logic i wanna ask how can i increase my logical power

Prashant Chaudhari August 22, 2014 at 11:12 pm - Reply

These 101 programs are enough for building core programming logic.
Very soon we are planning to launch video series for the same. That will
make things more easy.

Lahu Bhawar September 19, 2014 at 10:45 pm - Reply

It really helpsnice thank u

Prashant Chaudhari September 20, 2014 at 12:29 am - Reply

Hi Lahu, glad to know that it is helping you. Share this with your friends as
well
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
pooja agrawal September 20, 2014 at 8:22 pm - Reply

thank u so much it realy helped me alot to complete my assignment:)now i m little bit


confident that i cn also make a program

Prashant Chaudhari September 21, 2014 at 9:24 am - Reply

Wow! Nice pooja, keep it up.


I am glad to know that these programs have helped you.
Please share the link with your friends as well.

pooja agrawal September 23, 2014 at 12:33 am - Reply

once again thank u sir.


because of these programs i scored full marks in my practicl
test..

Prashant Chaudhari September 23, 2014 at 1:56 pm -


Reply

Oh wow !!
Congratulations pooja Thats a great news
. Keep it up! I really hope this motivates
your friends too

Dalvir singh December 21, 2014 at 12:05 am - Reply

Sir very helpful for basic concepts required for programming.thanks a lot. I actually gained

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
very much for them.

Prashant Chaudhari December 21, 2014 at 1:39 am - Reply

Its great to hear, Pls share the link with your friends and like the pages.
Thanks

Ravi shankar December 27, 2014 at 3:12 pm - Reply

Really helpful for the beginners to practice and understand.

Prashant Chaudhari December 27, 2014 at 6:27 pm - Reply

Thanks Ravi, glad to know that this has helped you, share the link with your
friends as well.

Prashant Chaudhari June 22, 2015 at 6:50 am - Reply

Thanks Ravi, share the blog with your friends

archit kumar January 20, 2015 at 1:19 am - Reply

Thankyou sir .for helping us

Prashant Chaudhari June 22, 2015 at 6:49 am - Reply

My pleasure, share the website with your friends.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Usha January 22, 2015 at 6:01 pm - Reply

Hi Sir,
Could u please help in the below given query
Thanks in Advance!!
A random array of elements is given. Program needs to find all the sections(sequences) in
the array that are in ascending order, find the sum of those sequences, then find the
largest sum and print the largest sum along with the sequence of numbers. For example if
the array is like
4, 5, 6, 2, 1, 2, 3, 4, 12, 6, 4, 2, 1, 5, 8, 9
Then ascending sequences in the given array are
4,5,6 with sum 15
1,2,3,4,12 with sum 22
1,5,8,9 with sum 23
So program should print the sequence 1 5 8 9 and the sum 23, as its the largest sum of
ascending sequences.
Please help me..!!

p.muthukumar January 31, 2015 at 5:50 pm - Reply

it is very use ful for the c program learners

Prashant Chaudhari June 22, 2015 at 8:01 am - Reply

Thank you share with your friends as well

neha garg February 3, 2015 at 4:38 pm - Reply

Thanks but not properly logics learn for me

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
neha garg February 3, 2015 at 4:39 pm - Reply

i m not satisfied in logics

Prashant Chaudhari June 22, 2015 at 8:09 am - Reply

Practice these programs, you will do well in programming


logic Best way is to sit with Friends when you practice,
that will clear initial hurdles

priyanka June 21, 2015 at 9:08 pm - Reply

you have done a tremendous work.. but while i was going through your programs i found
that ur prime number program is slightly wrong.. instead of i<=n-1" it should be "i<=n/2"
apart from that hats off to u.. keep on adding programs such as for pointers!

Prashant Chaudhari June 22, 2015 at 6:46 am - Reply

Hi Priyanka, thank you so much for your suggestions and those kind words.
Yes with your suggestions iterations will get reduced. It is an improvement
to the solution. Code is updated. Thanks for bringing this to notice, happy
programming !

Umesh Thakare September 5, 2015 at 6:17 pm - Reply

it is very easy to understand the c .


and to develop logic of c

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Prashant Chaudhari September 6, 2015 at 1:48 am - Reply

Great! Hope these programs are helping you a lot. We are launching
android app for these programs in next week. Share this website with your
friends. Cheers!!

Thunga September 6, 2015 at 8:38 pm - Reply

Its very helpfull ,thanks a lot

Prashant Chaudhari September 7, 2015 at 1:24 am - Reply

Glad to know that these programs are helping you. Please share it with
your friends.

priyanka arora September 11, 2015 at 10:32 pm - Reply

i was struggling thru gathering all programming logics at one place to revise for an
interview..this rily helped a lot ..thnx

Prashant Chaudhari September 12, 2015 at 11:42 am - Reply

Thats great! I hope I interview went well.


We have launched android app as well, search for kodegod.com in play
store.
Share this with your friends.

Nagarjuna October 1, 2015 at 8:04 pm - Reply

Hi, First I would like appreciated you for your hard work, All these programs are very
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
useful & interesting to me

Prashant Chaudhari October 6, 2015 at 9:56 pm - Reply

Thats great!! Why dont you try our android app as well?
Share it with your friends as well.
https://play.google.com/store/apps/details?
id=com.kodegod.fifthdi.kodegod

Matloob Chauhan October 6, 2015 at 5:24 pm - Reply

great logic and understandable for beginner


like me thank u so much respected
sirPrashant Chaudhari

Prashant Chaudhari October 6, 2015 at 9:58 pm - Reply

Wow, thanks for kind words. Share this website with your friends as well.
You can also try out android app. Here is the link
https://play.google.com/store/apps/details?
id=com.kodegod.fifthdi.kodegod

Naveen Kumar October 30, 2015 at 2:31 pm - Reply

the perfect basic address for who need to achieve in their life..
Good Job by poster

Prashant Chaudhari November 1, 2015 at 8:53 pm - Reply

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Thanks Naveen, share these programme with your friends. We have these
programs on android application as well, do check it out
https://play.google.com/store/apps/details?
id=com.kodegod.fifthdi.kodegod

Sarthak chauhan November 12, 2015 at 12:28 am - Reply

Very-very useful! This has helped me so much. Keep posting such amazing thing related
to programming.

Prashant Chaudhari November 13, 2015 at 12:02 am - Reply

Thanks Sarthak, share with your friends. Do check our android application as
well

ayush srivastava November 21, 2015 at 11:04 pm - Reply

thanks for the programs sir


can u please tell me this program.
Write a program to enter the name as string and convert it into given format. Eg :
SUBHASH KUMAR CHAWLA: S. K. CHAWLA

Prashant Chaudhari December 4, 2015 at 3:12 pm - Reply

You need to split the input using spaces and take first character of first two
words with a dot to print and then print last word as is. Pretty simple
, give it a try.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Aakash November 25, 2015 at 2:56 am - Reply

Thanks sir, for these programs.


I will do all these programs to build up my programming skills.

Prashant Chaudhari December 4, 2015 at 3:13 pm - Reply

Sure Aakash , check our android application as well. These problem will be
handy to you.

sagar December 3, 2015 at 10:32 pm - Reply

how can i reverse a whole line..


like
i am a boy
after reverse result will be
boy a am i

Prashant Chaudhari December 4, 2015 at 3:15 pm - Reply

Split the words using space and store into an array. Then print the array in
reverse order with a space. Hope this helps !

saravana December 18, 2015 at 5:53 pm - Reply

Sir, You are great.Thanks a lot.

Prashant Chaudhari December 18, 2015 at 6:18 pm - Reply

Pleasure !!! Check out our android application as well share it with your
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
friends as well

Leave A Response
Name (required) Comment

Email (required)

Website

Post Comment

RECENT TWEETS RECENT POSTS CATEGORIES

Follow me on Twitter Top Motivational Videos from YouTube Finance (1)

101 Programs to build your Programming Inspirational Videos (1)


Logic [using C Programming]
Learn C Programming (102)
Define a structure Employee having
elements emp_id, name, DOB, DOJ etc. Learn Programming (102)
Accept data and reprint it. (use structure
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
within structure)
Motivational Videos (1)

Define a structure Student having fields


Programming (1)
roll_no, name, marks, etc, for 5 students,
accept data and reprint
Resources (100)
Define a structure Employee having
elements emp_id, name,etc. Accept data Tips-Tricks-Tweaks (1)
and reprint it
Troubleshoot (2)
Write a program to check if the given
string is palindrome or not Videos (1)

Write a program to reverse the given Viral Videos (1)


string in C language

Wordpress (3)

Copyright 2011 - 2012 KodeGod.com. All rights reserved. Created by Fifth Dimension Technologies, Hosted on MagicHost. Back to Top

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com