Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, February 10, 2011

C14 : Print numbers upto a given limit

Back to Home   &  C


A ))) //Program to print numbers upto 20 using While loop

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=0;
while(i<=20)
{
printf("%d\n\n",i);
i++;
}
getch();
}
---------------------------------------------------------
Output
0
1
2
..
..
20
===============================================

B ))) //Program to print numbers from  20 to 1 using While loop

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=20;
while(i>0)
{
printf("%d\n\n",i);
i--;
}
getch();
}
---------------------------------------------------------
Output
20
19
18
..
..
2
1
===============================================
C ))) //Program to print numbers from  100 to 60 using Do-While loop



//Program to print the numbers from 100 to 60 using do-while loop
#include<stdio.h>
#include<conio.h>
void main()
 {
 clrscr();
 int i=100;
 do
 {
 printf("%d\n",i);
 i--;
 }
 while(i>=60);
 getch();
 }

---------------------------------------------------------
Output
100
99
98
..
..
61
60
===============================================
Back to Home   &  C



C13 : Read temperature and convert into celcious

Back to Home   &  C


//Program to read temperature and convert into celcious

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float f,c;
printf("Enter temperature\n");
scanf("%f",&f);
c=f-32/1.8;
printf("Temperature in Celcious=%f",c);
getch();
}
--------------------------------------------------------
Output
Enter temperature
12.34
Temperature in Celcious=5.437778
==========================================
Back to Home   &  C

C12. Print a multiplication table


Back to Home   &  C


//Program to print a multiplication table

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=0,n,i;
printf("\n\nEnter the no for multiplication table\n\n");
scanf("%d",&n);
for(i=1;i<=10;i=i+1)
{
a=i*n;
printf("\n\n%d*%d=%d\n\n",i,n,a);
}
getch();
}
-----------------------------------------------------------------------
Output
Enter the no for multiplication table
2
1*2=2
2*2=4
3*2=6
.
.
.
10*2=20
=========================================

Back to Home   &  C

C11 : Read nos and display any of the given number as user's choice


Back to Home   &  C


//To read 10 nos and display any of the given number as user's choice

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,a[10];
printf("Enter 10 nos\n");
for(i=0;i<=n;i++)
{
   scanf("%d",&a[i]);
}
       //printf("Which no you want to display\n");
      //scanf("%d",&n);
for(i=0;i<=n;i++)
{
     printf("%d\n",a[n-1]);
}
getch();
}
----------------------------------------------------------------------------
Output
(Please correct this ..May be some error in output...)
Hint : Enter any 10 number..and the user want to display 7th number..
=========================================

Back to Home   &  C

C10 : Read a string and print it


Back to Home   &  C


A ))) //Read a string and print it

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char n[20];
printf("Enter your name\n");
scanf("%s",n);
printf("Welcome %s",n);
getch();
}
--------------------------------------------------------------------
Output
Enter your name
IGNOU
Welcome IGNOU
=============================================
B ))) //Print a string 5 times (Using While Loop)


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=1;
while(i<=5)
{
printf("Hai\n");
i++;
}
getch();
}


--------------------------------------------------------------------
Output
Hai
Hai
Hai
Hai
Hai
=============================================
C ))) //Print a string n times (Using for Loop)



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
printf("Enter limit value\n");
scanf("%d",&n);
for(i=0;i<=n;i++)
 {
 printf("IGNOU\n");
 }
getch();
}


--------------------------------------------------------------------
Output
Enter limit value
4
IGNOU
IGNOU
IGNOU
IGNOU
=============================================

Back to Home   &  C