Professional Documents
Culture Documents
in
https://www.facebook.com/IGNOUHelp.in
There are six questions in this assignment, which carry 80 marks. Rest 20 marks
are for viva-voce.
Answer all the questions. You may use illustrations and diagrams to enhance the
explanations.
Please go through the guidelines regarding assignments given in the Programme
Guide for the format of presentation. Insert comments in the coding for better
understanding.
Question 1:
Write a C program to find out perfect numbers from 1 and 50
. Solution :
#include<stdio.h>
#include<conio.h> voidmain()
{
voidperfect(); clrscr(); perfect(); getch();
}
void perfect()
{
int n,i,s,lim; lim=1;
while(lim<=50) { i=1;s=0;
while(i<lim)
{
if(lim%i==0)
{
s=s+i;
} i++;
}
if(s==lim)
Binary
number Octal
values 000
0
001
1
010
2
011
3
100
4
101
5
110
6
111
7
Binary to octal chart
So (1011010101001101)2 = (132515)8
For more IGNOU solved assignments please visit - www.IGNOUHelp.in c
program to convert binary to octal
#include<stdio.h>
int main(){
while(binaryNumber!=0){
remainder=binaryNumber%10;
octalNumber=octalNumber+remainder*j;
j=j*2;
binaryNumber=binaryNumber/10;
}
printf("Equivalent octal
value: %lo",octalNumber);
return 0;
}
Sample output:
Question 3 : Write the function strreplace(s, chr, repl_chr) which will replace each
occurrences of character chr with the character repl_chr in the string s. The function
returns the number of replacements. Place the source code of this function in a file named
strreplace.c
Solution :
if (oldlen != newlen) {
for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q
+ oldlen)
count++;
/* this is undefined if p - str > PTRDIFF_MAX */
retlen = p - str + strlen(p) + count * (newlen - oldlen);
} else
retlen = strlen(str);
return ret;
}
#include<stdio.h>
#include<conio.h>
int main()
{
char str[30];
char *p,*t;
printf("Enter any string : ");
gets(str);
for(p=str ; *p!=NULL ;
p++); for(t=str, p-- ; p>=t; )
{
if(*p==*t)
{
p--;
t++;
}
Solution :
#include <stdio.h>
}
Main (int argc,char *argv[])
{ int pounds;
if(argc != 2)
Solution :
#include<stdio.h>
#include<conio.h> void main()
{
int n,i,k;
struct employee
{
char name[50],des[30],mon[10],level; int empid,accno;
float hra,da,cca,ca,gpf,grossal,totdeduc,netsal,basic;
}emp[10];
clrscr();
printf("ENTER THE NUMBER OF EMPLOYEE: ");
scanf("%d",&n); for(i=1;i<=n;i++)
{
printf("ENTER NAME OF THE EMPLOYEE:");
scanf("%s",emp[i].name);
printf("ENTER DESIGANTION OF THE EMPLOYEE:"); scanf("%s",emp[i].des);
printf("ENTER MONTH:"); scanf("%s",emp[i].mon); printf("ENTER EMPLOYEE ID:");
scanf("%d",&emp[i].empid); printf("ENTER ACCNO:");
scanf("%d",&emp[i].accno); printf("BASIC PAY: ");
scanf("%f",&emp[i].basic);
printf("ENTER CITY LEVEL: ");
scanf("%s",&emp[i].level);
for(i=1;i<=n;i++)
{
emp[i].hra=emp[i].basic*0.30; if(emp[i].basic<=6500) emp[i].ca=100; else
{
if(emp[i].basic>6500&&emp[i].basic<=8000) emp[i].ca=400; else emp[i].ca=800;
}
emp[i].da=emp[i].basic/2; if(emp[i].level=='a'||emp[i].level=='A') emp[i].cca=400; else
{
if(emp[i].level=='b'||emp[i].level=='B') emp[i].cca=100;
else emp[i].cca=50;
}
emp[i].gpf=emp[i].basic * 0.075;
emp[i].grossal=emp[i].basic+emp[i].hra+emp[i].da+emp[ i].cca; emp[i].totdeduc=emp[i].gpf;
emp[i].netsal=emp[i].grossal-emp[i].totdeduc;
}
for(i=1;i<=n;i++)
{
do
{
clrscr();
printf("V R SIDDHARTHA ENGINEERNG COLLEGE");
printf("KANURU::VIJAYAWADA-7"); printf("PAY SLIP");
printf(":%s
:%d",emp[i].des,emp[i].accno);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
printf(" -
----");
printf("<-------------------
- EARNINGS >
D
E
D
U
C
T
I
<------------------- O >");
N
S
printf("BASIC=%f
.F.=%.2f",emp[i].basic,emp[i].gpf);
printf("D.A=%.2f TAX=",emp[i].da); printf("H.R.A=%.2f .F. LOAN=",emp[i].hra);
printf("C.C.A=%.2f
.I.C=",emp[i].cca); printf("--------------
------------------------
----------");
printf("GROSS SALARY=%.2f DEDUCTIONS=%.2f "
,emp[i].grossal,emp[i].totdeduc); printf("--------------------------------------
------------");
printf("NET SALARY=%.2f",emp[i].netsal); printf("--------------------------------------
------------");
printf("SIGNATURE"); printf("1 TO NEXT ......");
scanf("%d",&k); }while(k==2);
}
getch();
}
https://www.facebook.com/IGNOUHelp.in