O Level Project C Language PDF
O Level Project C Language PDF
O- LEVEL PROJECT
For NIELIT, New Delhi.
This is to certify that the Project work done at NIELIT, New Delhi, titled
‘PROGRAMMING IN C-LANGUAGE’ by Mr. KUNDAN KUMAR (NIELIT
Registration No- 1085660) in partial fulfillment of NIELIT ‘O’ Level
Examination has been found satisfactory. This report has not been submitted
for any other examination and does not form part of any other course
undergone by the candidate.
It is further certifies that he/she has appeared in all the four modules of
NIELIT ‘O’ Level Examination.
Signature
Name:
(Institute PROV No./FULL No.)
(or)
Head of the Organization/Division:
Name of the Organization:
Address:
(or)
Name of the Guide/Supervisor: xxxxxxxxx
Qualification: “Bachelor in Computer Science and Engineering”
3
Programs written in C are efficient and fast. This is due to its variety of data
types and powerful operations. It many times faster than Basic. For example, a
program to increment a variable from 0 to 15000 takes about one second in C
while it takes more than 50 seconds in an interpreter basic.
There are only 32 keywords in ANSI C and its strength lies in its built in
functions. Several standard functions are available which can be used for
developing programs.
C is highly portable . This means that C programs written for one computer
can be run on another with little or no modification. Portability is important if
we plan to use a new computer with different operating system.
4
C language is well suited for structured programming , thus requiring the user
to think of a problem in terms of function modules or blocks. A proper
collection of these modules would make a complete program. This modular
structure makes program debugging, testing and maintenance easier.
1-Windows Xp or Above
2-C editor
PROGRAM CODING :
SOME EXAMPLE OF C PROGRAMMING-
#include <stdio.h>
#include<conio.h>
Main()
int number;
float amount;
number= 100;
amount=30.75+75.25;
printf(“%d\n”, number);
printf(“%5.2f”,amount);
106.10
7
#include<stdio.h>
int main(){
int i,f=1,num;
scanf("%d",&num);
for(i=1;i<=num;i++)
f=f*i;
return 0;
output:
Enter a number: 8
#include <stdio.h>
int main()
scanf("%f", &celsius);
return 0;
output:
#include <stdio.h>
int main()
{
int n, i, range;
printf("Enter an integer: ");
scanf("%d",&n);
printf("Enter the range: ");
scanf("%d", &range);
for(i=1; i <= range; ++i)
{
printf("%d * %d = %d \n", n, i, n*i);
}
return 0;
}
output:
Enter an integer: 12
Enter the range: 8
12 * 1 = 12
12 * 2 = 24
12 * 3 = 36
12 * 4 = 48
12 * 5 = 60
12 * 6 = 72
12 * 7 = 84
12 * 8 = 96
10
#include<stdio.h>
int main()
{
int num, rem, rev = 0;
#include<stdio.h>
#include<string.h>
int main() {
int num, i, count = 0;
char str1[10], str2[10];
printf("nEnter a number:");
scanf("%d", &num);
if (count == 0)
printf("%d is a prime number", num);
else
printf("%d is not a prime number", num);
return 0;
}
12
#include<stdio.h>
int main() {
int first, second, sum, num, counter = 0;
printf("Enter the term : ");
scanf("%d", &num);
printf("\nEnter First Number : ");
scanf("%d", &first);
return (0);
}
output:
Enter the term : 5
Enter First Number : 1
Enter Second Number : 3
Fibonacci Series : 1 3 4 7 11 18 29
13
#include <stdio.h>
#include<conio.h>
void main ()
enum light {
};
int ch;
scanf(“%d”, &ch);
switch (ch)
Case RED:
Printf(“Stop”);
Break;
case YELLOW:
printf(“Wait”);
break;
case GREEN:
14
printf(“Go”);
break;
getch();
#include <stdio.h>
#include <conio.h>
void main()
char a[100];
int len,i,word=1;
clrscr();
gets(a);
len=strlen(a);
for(i=0;i<len;i++)
word=word+1;
}
15
getch();
output:
#include <stdio.h>
#include <conio.h>
void main()
char a[100];
int len,i,vow=0;
clrscr();
gets(a);
len=strlen(a);
for(i=0;i<len;i++)
{
16
vow=vow+1;
getch();
output:
#include <stdio.h>
int main()
scanf("%d",&rows);
printf(" ");
17
while(k != 2*i-1)
printf("* ");
++k;
printf("\n");
return 0;
output:
***
*****
*******
*********
18
#include <stdio.h>
int main()
int i, j;
printf("Enter the uppercase character you want to print in last row: ");
scanf("%c",&input);
for(j=1;j<=i;++j)
printf("%c", alphabet);
++alphabet;
printf("\n");
return 0;
}
19
output:
BB
CCC
DDDD
EEEEE
#include <stdio.h>
int main()
int i, j, rows;
scanf("%d",&rows);
printf("%d ",j);
20
printf("\n");
return 0;
output:
12
123
1234
12345
#include<stdio.h>
#include<conio.h>
#define ROW 3
#define COL 3
void main()
int a[ROW][COL];
21
dis(a,ROW,COL);
trans(a,ROW,COL);
dis(a,ROW,COL);
getch();
int j,l;
for(j=0;j<i;j++)
for(l=0;l<k;l++)
printf("%d ",d[j][l]);
printf("\n");
}
22
int i,j,temp;
for(i=0;i<k;i++)
for(j=i+1;j<l;j++)
temp=mat[i][j];
mat[i][j]=mat[j][i];
mat[j][i]=temp;
output:
The matrix is
123
456
789
147
258
369
23
#include<stdio.h>
#include<conio.h>
main(){
int a[5],i;
read(a,5);
dis(a,5);
inverse(a,5);
dis(a,5);
getch();
int j;
for(j=0;j<i;j++)
scanf("%d",&c[j]);
24
fflush(stdin);
int j;
for(j=0;j<i;j++)
printf("%d ",d[j]);
printf("\n");
int i,temp;
j--;
for(i=0;i<(j/2);i++)
temp=inver_a[i];
inver_a[i]=inver_a[j];
inver_a[j]=temp;
j--;
}
25
output:
The list is
12345
The list is
52341
#include<stdio.h>
#define SIZE 50
struct student {
char name[30];
int rollno;
int sub[3];
};
void main() {
26
clrscr();
scanf("%d", &n);
scanf("%s", &st[i].name);
scanf("%d", &st[i].rollno);
scanf("%d", &st[i].sub[j]);
total = 0;
a[i] = total;
/* (ii) for loop to list out the student's roll numbers who
max = 0;
max = st[i].sub[j];
ni = i;
max = 0;
max = a[i];
ni = i;
getch();
#include <stdio.h>
#include <conio.h>
void main()
char s[100];
int len,i;
clrscr();
gets(s);
len=strlen(s);
printf("\n");
for(i=0;i<len;i++)
29
printf("%c",s[i]-32);
else
printf("%c",s[i]);
getch();
output:
CHANDAN
#include<stdio.h>
int main()
int i,range;
scanf("%d",&range);
30
arr[0]=0;
arr[1]=1;
for(i=2;i<range;i++){
for(i=0;i<range;i++)
printf("%ld ",arr[i]);
return 0;
output:
#include <stdio.h>
#include <conio.h>
void main()
int n,*p,sum=0,i;
float avg;
clrscr();
scanf("%d",&n);
p=(int *) malloc(n*2);
if(p==NULL)
exit();
for(i=0;i<n;i++)
scanf("%d",(p+i));
}
32
for(i=0;i<n;i++)
sum=sum+*(p+i);
avg=(float)sum/n;
getch();
output:
ENTER NUMBER 1: 23
ENTER NUMBER 2: 67
#include<stdio.h>
int main() {
int n,i;
int sum=0;
scanf("%d",&n);
sum = (n * (n + 1)) / 2;
if (i!=n)
printf("%d = %d ",i,sum);
return 0;
OUTPUT: