When we install both Ubuntu and XP in our system.It'll herritate us by going into Ubuntu when we reboot the system.
So to overcome from this,we have to set XP as default O.S..To do this,we have to change a small setting in Ubuntu.
Type this command in command line:
sudo gedit /boot/grub/menu.lst
(search where grub folder located).If you don't have gedit(notepad) in Kubuntu.To install the gedit type this command in terminal:
sudo kate /boot/grub/menu.lst
Then press Enter.One text document opens when we press Enter.In that document these lines will be located:
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default 0
When we reboot the system,have to see at which line XP placed along with Ubuntu.Next we have to paste the XP Number in last line(default 0) in document means We should Enter the XP number that we we have seen when the system booting,instead of "0".Later save the the doucument and close it and restart the system.
Naturally Kubuntu and Ubuntu has booting number "6".So we have to Enter "6"instead of "0"in the document last line.i.e.default 6 in last line of document.
Saturday, December 11, 2010
Sunday, November 28, 2010
Write a program toAsk student to Enter his roll number ,three subject marks obtained by Roll no.1 and repeat it for3timesAndprint them
#include
#include
int main()
{
int result [3][4];
int i, j;
for (i=0;i<3;i++)
{
j=0;
printf ("\nEnter the Roll number:-");
scanf ("%d", &result [i][j]);
for (j=1;j<4;j++)
{
printf ("\nEnter the marks of subject no.%2d\n", j);
scanf ("%d", &result [i][j]);
}
}
printf ("The stored values are:\n");
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
printf ("%4d", result [i][j]);
}
printf ("\n");
}
getch ();
}
#include
int main()
{
int result [3][4];
int i, j;
for (i=0;i<3;i++)
{
j=0;
printf ("\nEnter the Roll number:-");
scanf ("%d", &result [i][j]);
for (j=1;j<4;j++)
{
printf ("\nEnter the marks of subject no.%2d\n", j);
scanf ("%d", &result [i][j]);
}
}
printf ("The stored values are:\n");
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
printf ("%4d", result [i][j]);
}
printf ("\n");
}
getch ();
}
Labels:
C-Programming
Write a program to print the values in a matrix table
#include
#include
main()
{
int a[10][10],i,j,r,c;
printf("Enter order or matrix:");
scanf("%d%d", &r,&c);
printf("Enter %d values ", r*c);
for(i=0;i
for(j=0;j
scanf("%d", &a[i][j]);
printf("\n Element of array a: ");
for(i=0;i
{
printf("\n");
for(j=0;j
{
printf("%d\t",a[i][j]);
}
}
getch();
}
#include
main()
{
int a[10][10],i,j,r,c;
printf("Enter order or matrix:");
scanf("%d%d", &r,&c);
printf("Enter %d values ", r*c);
for(i=0;i
for(j=0;j
scanf("%d", &a[i][j]);
printf("\n Element of array a: ");
for(i=0;i
{
printf("\n");
for(j=0;j
{
printf("%d\t",a[i][j]);
}
}
getch();
}
Labels:
C-Programming
Write a program to print the highest score of the given array?
#include
#include
#define NUM_STUDENTS 25
#define NUM_TESTS 10
int get_highest(int a[][NUM_TESTS], int row, int col);
int main()
{
int grades[NUM_STUDENTS][NUM_TESTS] = { {55, 60, 65},
{85, 90, 95} };
int num_students = 2;
int num_tests = 3;
int high_test;
high_test = get_highest( grades, num_students, num_tests);
printf("The highest score is %d.\n", high_test);
getch();
}
int get_highest(int a[][NUM_TESTS], int row, int col)
/* Assumes that there is at least one element */
{
int i, j;
int highest = a[0][0];
for( i = 0; i < row; i++)
for( j = 0; j < col; j++)
if ( a[i][j] > highest)
highest = a[i][j];
return highest;
}
#include
#define NUM_STUDENTS 25
#define NUM_TESTS 10
int get_highest(int a[][NUM_TESTS], int row, int col);
int main()
{
int grades[NUM_STUDENTS][NUM_TESTS] = { {55, 60, 65},
{85, 90, 95} };
int num_students = 2;
int num_tests = 3;
int high_test;
high_test = get_highest( grades, num_students, num_tests);
printf("The highest score is %d.\n", high_test);
getch();
}
int get_highest(int a[][NUM_TESTS], int row, int col)
/* Assumes that there is at least one element */
{
int i, j;
int highest = a[0][0];
for( i = 0; i < row; i++)
for( j = 0; j < col; j++)
if ( a[i][j] > highest)
highest = a[i][j];
return highest;
}
Labels:
C-Programming
Write a program to find out the largest and smallest values of a Matrix?
#include
#include
main()
{
int a[10][10];
int l,s,i,j,p,q;
printf("Enter the order of matrix: ");
scanf("%d%d", &p,&q);
printf("\n Enter %d values : ",p*q);
for(i=0;i
{
for(j=0;j
scanf("%d", &a[i][j]);
}
l=0;
s=a[0][0];
for(i=0;i
{
for(j=0;j
{
if(l
l=a[i][j];
if(a[i][j]
s=a[i][j];
}
}
printf("\n\n");
printf("Element of matrix a: ");
for(i=0;i
{
printf("\n");
for(j=0;j
{
printf("%d\t", a[i][j]);
}
}
printf("\n The biggest values: %d", l);
printf("\n The smallest value:%d",s);
getch();
}
#include
main()
{
int a[10][10];
int l,s,i,j,p,q;
printf("Enter the order of matrix: ");
scanf("%d%d", &p,&q);
printf("\n Enter %d values : ",p*q);
for(i=0;i
{
for(j=0;j
scanf("%d", &a[i][j]);
}
l=0;
s=a[0][0];
for(i=0;i
{
for(j=0;j
{
if(l
l=a[i][j];
if(a[i][j]
s=a[i][j];
}
}
printf("\n\n");
printf("Element of matrix a: ");
for(i=0;i
{
printf("\n");
for(j=0;j
{
printf("%d\t", a[i][j]);
}
}
printf("\n The biggest values: %d", l);
printf("\n The smallest value:%d",s);
getch();
}
Labels:
C-Programming
Write a program to read data and determine the following ,Total marks obtain by each student,The highest marks in each subject with Rollno, highest st
#include
int main()
{
int result[10][5],i,j,k,total,maxr,maxm;
for(i=0;i<5;i++) {
total=0;
for(j=0;j<4;j++)
{
if(j==0)
puts("Enter Roll number\t");
else if(j==1)
puts("Enter 1st subject marks\t");
else if(j==2)
puts("Enter 2nd subject marks\t");
else if(j==3)
puts("Enter 3rd subject marks\t");
scanf("%d",&result[i][j]);
if(j!=0)
total+=result[i][j];
}
result[i][j]=total;
}
puts("Mark sheet");
printf("\n%6s%6s%6s%6s%6s\n","Roll","1st","2nd","3rd","Total");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%6d",result[i][j]);
} printf("\n");
}
puts("Press any key....");
getch();
puts("Roll number with total");
printf("\n%6s%6s\n","Roll","Total");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{ if((j==0)||(j==4))
printf("%6d",result[i][j]);
}
printf("\n");
}
for(i=1;i<4;i++)
{
for(j=0;j<5;j++)
{
if(j==0)
{
maxm=result[j][i];
maxr=result[j][0];
}
else if(result[j][i]>maxm)
{
maxm=result[j][i];
maxr=result[j][0];
}
}
if(i==1)
printf("\nMaximum marks in sub1 is %d, Roll number %d",maxm,maxr);
else if(i==2)
printf("\nMaximum marks in sub2 is %d, Roll number %d",maxm,maxr);
else if(i==3)
printf("\nMaximum marks in sub3 is %d, Roll number %d",maxm,maxr);
}
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(j==4)
{
if(i==0)
{
maxm=result[i][j];
maxr=result[i][0];
}
else if(result[i][j]>maxm)
{
maxm=result[i][j];
maxr=result[i][0];
}
}
}
}
printf("\nMaximum total is %d and Roll number %d",maxm,maxr);
getch();
}
int main()
{
int result[10][5],i,j,k,total,maxr,maxm;
for(i=0;i<5;i++) {
total=0;
for(j=0;j<4;j++)
{
if(j==0)
puts("Enter Roll number\t");
else if(j==1)
puts("Enter 1st subject marks\t");
else if(j==2)
puts("Enter 2nd subject marks\t");
else if(j==3)
puts("Enter 3rd subject marks\t");
scanf("%d",&result[i][j]);
if(j!=0)
total+=result[i][j];
}
result[i][j]=total;
}
puts("Mark sheet");
printf("\n%6s%6s%6s%6s%6s\n","Roll","1st","2nd","3rd","Total");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%6d",result[i][j]);
} printf("\n");
}
puts("Press any key....");
getch();
puts("Roll number with total");
printf("\n%6s%6s\n","Roll","Total");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{ if((j==0)||(j==4))
printf("%6d",result[i][j]);
}
printf("\n");
}
for(i=1;i<4;i++)
{
for(j=0;j<5;j++)
{
if(j==0)
{
maxm=result[j][i];
maxr=result[j][0];
}
else if(result[j][i]>maxm)
{
maxm=result[j][i];
maxr=result[j][0];
}
}
if(i==1)
printf("\nMaximum marks in sub1 is %d, Roll number %d",maxm,maxr);
else if(i==2)
printf("\nMaximum marks in sub2 is %d, Roll number %d",maxm,maxr);
else if(i==3)
printf("\nMaximum marks in sub3 is %d, Roll number %d",maxm,maxr);
}
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(j==4)
{
if(i==0)
{
maxm=result[i][j];
maxr=result[i][0];
}
else if(result[i][j]>maxm)
{
maxm=result[i][j];
maxr=result[i][0];
}
}
}
}
printf("\nMaximum total is %d and Roll number %d",maxm,maxr);
getch();
}
Labels:
C-Programming
Write a program that reads in four integers and determines and prints the largest and the smallest integers in the group?
#include
#include
#define MAX_INTS 4
int main()
{
int min = INT_MAX;
int max = INT_MIN;
int a[ MAX_INTS ];
int i;
for (i = 0; i < MAX_INTS; i++)
{
printf( "Enter number %d of %d : ", (i + 1), MAX_INTS);
scanf( "%d", &a[i] );
if ( a[i] < min) min = a[i];
if ( a[i] > max) max = a[i];
}
printf("%d is the smallest number\n", min);
printf("%d is the largest number\n", max);
return 0;
}
#include
#define MAX_INTS 4
int main()
{
int min = INT_MAX;
int max = INT_MIN;
int a[ MAX_INTS ];
int i;
for (i = 0; i < MAX_INTS; i++)
{
printf( "Enter number %d of %d : ", (i + 1), MAX_INTS);
scanf( "%d", &a[i] );
if ( a[i] < min) min = a[i];
if ( a[i] > max) max = a[i];
}
printf("%d is the smallest number\n", min);
printf("%d is the largest number\n", max);
return 0;
}
Labels:
C-Programming
Write the program to calculate the Median of a given array
#include
main()
{
int i,j,n;
float median,t;
printf("Enter the size of the array\n");
scanf("%d",&n);
float a[n];
printf("Enter the values\n");
for(i=0;i
scanf("%f",&a[i]);
for(i=0;i
{
for(j=1;j
{
if(a[j-1]
{
t=a[j-1];
a[j-1]=a[j];
a[j]=t;
}
else
continue;
}
}
if(n%2==0)
median=(a[n/2]+a[n/2+1])/2;
else
median=a[n/2+1];
for(i=0;i
printf(" %.2f",a[i]);
printf("\nMedian is =%f\n",median);
getch();
}
main()
{
int i,j,n;
float median,t;
printf("Enter the size of the array\n");
scanf("%d",&n);
float a[n];
printf("Enter the values\n");
for(i=0;i
scanf("%f",&a[i]);
for(i=0;i
{
for(j=1;j
{
if(a[j-1]
{
t=a[j-1];
a[j-1]=a[j];
a[j]=t;
}
else
continue;
}
}
if(n%2==0)
median=(a[n/2]+a[n/2+1])/2;
else
median=a[n/2+1];
for(i=0;i
printf(" %.2f",a[i]);
printf("\nMedian is =%f\n",median);
getch();
}
Labels:
C-Programming
write a program to Reverse the digits by using do-while loop
#include
#include
main()
{
int number = 123;
int rightMostNumber = 0;
int temp = 0;
temp = number;
do
{
rightMostNumber = 10*rightMostNumber + temp % 10;
temp = temp/10;
} while (temp);
printf ("\nThe number %d reversed is %d\n", number, rightMostNumber );
getch();
}
#include
main()
{
int number = 123;
int rightMostNumber = 0;
int temp = 0;
temp = number;
do
{
rightMostNumber = 10*rightMostNumber + temp % 10;
temp = temp/10;
} while (temp);
printf ("\nThe number %d reversed is %d\n", number, rightMostNumber );
getch();
}
Labels:
C-Programming
write a program to find given number is palidrome or not by using while loop?
#include
#include
main()
{
int n,t,s,r;
printf(“Ent er any number:”);
scanf(“%d”,&n);
t=n;
s=0;
while (n>0)
{
r=n%10;
s=(s*10)+r;
n=n/10;
}
if(t==s)
printf(“%d is a Palindrome number”, t);
else
printf(“%d is not a Palindrome number”, t);
getch();
}
#include
main()
{
int n,t,s,r;
printf(“Ent er any number:”);
scanf(“%d”,&n);
t=n;
s=0;
while (n>0)
{
r=n%10;
s=(s*10)+r;
n=n/10;
}
if(t==s)
printf(“%d is a Palindrome number”, t);
else
printf(“%d is not a Palindrome number”, t);
getch();
}
Labels:
C-Programming
write a program To print armstrong number using while loop
#include
#include
main()
{
int n,t,s,r;
printf(“Ent er any number:”);
scanf(“%d”,&n);
t=n;
s=0;
while (n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(t==s)
printf(“%d is a Armstrong number”, t);
else
printf(“%d is not a Armstrong number”, t);
getch();
}
#include
main()
{
int n,t,s,r;
printf(“Ent er any number:”);
scanf(“%d”,&n);
t=n;
s=0;
while (n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(t==s)
printf(“%d is a Armstrong number”, t);
else
printf(“%d is not a Armstrong number”, t);
getch();
}
Labels:
C-Programming
write a program to find given number is prime number or not by using while loop
#include
#include
main()
{
int n,i,k;
printf(“Enter any number:”);
scanf(“%d”, &n);
i=1;
k=0;
while(i<=n)
{
if(n%i==0)
k=k+1;
i++;
}
if(k==2)
printf(“%d is a prime number”,n);
else
printf(“%d is not a prime number”,n);
getch();
}
#include
main()
{
int n,i,k;
printf(“Enter any number:”);
scanf(“%d”, &n);
i=1;
k=0;
while(i<=n)
{
if(n%i==0)
k=k+1;
i++;
}
if(k==2)
printf(“%d is a prime number”,n);
else
printf(“%d is not a prime number”,n);
getch();
}
Labels:
C-Programming
write a programTo print average of odd numbers below user given range
#include
#include
main()
{
int i,r,c,t;
float a;
printf(“Enter the range:”);
scanf(“%d”, &r);
i=1; c=0; t=0;
while(i<=r)
{
if (i%2!=0)
{
t=t+i;
c++;
}
i++;
}
a=t/c;
printf(“\nThe average of odd numbers below &d: %f”,r,a);
getch();
}
#include
main()
{
int i,r,c,t;
float a;
printf(“Enter the range:”);
scanf(“%d”, &r);
i=1; c=0; t=0;
while(i<=r)
{
if (i%2!=0)
{
t=t+i;
c++;
}
i++;
}
a=t/c;
printf(“\nThe average of odd numbers below &d: %f”,r,a);
getch();
}
Labels:
C-Programming
write a program to print sum of digits upto given number
#include
#include
int main(void)
{
long sum = 1L;
int j = 1;
int count = 10;
int i;
for(i = 1 ; i <= count ; i++)
{
sum = 1L;
j=1;
printf("\n1");
while(j < i){
sum += ++j;
printf("+%d", j);
}
printf(" = %ld\n", sum);
}
getch();
}
#include
int main(void)
{
long sum = 1L;
int j = 1;
int count = 10;
int i;
for(i = 1 ; i <= count ; i++)
{
sum = 1L;
j=1;
printf("\n1");
while(j < i){
sum += ++j;
printf("+%d", j);
}
printf(" = %ld\n", sum);
}
getch();
}
Labels:
C-Programming
To print floy’s triangle using for loop
#include
#include
main()
{
int i,j,t,row;
printf(“Enter number of rows:”);
scanf(“%d”,&row);
t=1;
for(i=0;i|
{
for(j=0;j<=i;j++)
{
if(t<10)
printf(“%d “,t);
else
printf(“%d “,t);
t++;
}
printf(“\n”);
}
getch();
}
#include
main()
{
int i,j,t,row;
printf(“Enter number of rows:”);
scanf(“%d”,&row);
t=1;
for(i=0;i
{
for(j=0;j<=i;j++)
{
if(t<10)
printf(“%d “,t);
else
printf(“%d “,t);
t++;
}
printf(“\n”);
}
getch();
}
Labels:
C-Programming
write a program To print asterisks graph using for loop
#include
#include
main()
{
int i,j,row;
printf(“Enter number of rows:”);
scanf(“%d”,&row);
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
printf(“* “);
}
printf(“\n”);
}
getch();
}
#include
main()
{
int i,j,row;
printf(“Enter number of rows:”);
scanf(“%d”,&row);
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
printf(“* “);
}
printf(“\n”);
}
getch();
}
Labels:
C-Programming
Write a program to check the given character whether it is vowel or consonant?
#include
#include
main()
{
char a;
printf("Enter any small letter(a-z) \n");
scanf("%c",&a);
//a = getchar();
if((a =='a') || (a == 'e') || (a =='i') || (a == 'o') || (a == 'u'))
printf("It is a vowel ");
else
printf("It is a consonant");
getch();
}
#include
main()
{
char a;
printf("Enter any small letter(a-z) \n");
scanf("%c",&a);
//a = getchar();
if((a =='a') || (a == 'e') || (a =='i') || (a == 'o') || (a == 'u'))
printf("It is a vowel ");
else
printf("It is a consonant");
getch();
}
Labels:
C-Programming
Write a program to print the given year is a leap year or not?
#include
main()
{
int year;
printf("Enter a year\n");
scanf("%d",&year);
if(year%4==0 && year%100!=0 ||year%400==0)
printf("Given year is a leap year");
else
printf("Given year is not a leap year");
getch();
}
main()
{
int year;
printf("Enter a year\n");
scanf("%d",&year);
if(year%4==0 && year%100!=0 ||year%400==0)
printf("Given year is a leap year");
else
printf("Given year is not a leap year");
getch();
}
Labels:
C-Programming
Write a program to print result of student?
#include
#include
main()
{ int m1,m2,m3,m4,m5,m6,total;
char result, grade,name[15];
float avg;
printf("Enter student name:");
scanf("%s", name);
printf("\n Enter 6 marks:");
scanf("%d%d%d%d%d%d", &m1, &m2, &m3, &m4, &m5, &m6);
total=m1+m2+m3+m4+m5+m6;
avg=total/6;
if(avg>40)
{
result = 'p';
if(avg>75)
grade='d';
else if(avg>60 && avg<=75)
grade='a';
else if(avg>50 && avg<=60)
grade='b';
else
grade='c';
}
else
result='f';
printf("\nstudent name : %s", name);
printf("\nMarks :");
printf("\n%d\t%d\t%d\t%d\t%d\t%d\t",m1,m2,m3,m4,m5,m6);
printf("\nAverage marks : %f",avg);
if(result=='p')
printf("\nResult :pass");
else
printf("\Result :fail");
printf("\Grade :%c",grade);
getch();
}
#include
main()
{ int m1,m2,m3,m4,m5,m6,total;
char result, grade,name[15];
float avg;
printf("Enter student name:");
scanf("%s", name);
printf("\n Enter 6 marks:");
scanf("%d%d%d%d%d%d", &m1, &m2, &m3, &m4, &m5, &m6);
total=m1+m2+m3+m4+m5+m6;
avg=total/6;
if(avg>40)
{
result = 'p';
if(avg>75)
grade='d';
else if(avg>60 && avg<=75)
grade='a';
else if(avg>50 && avg<=60)
grade='b';
else
grade='c';
}
else
result='f';
printf("\nstudent name : %s", name);
printf("\nMarks :");
printf("\n%d\t%d\t%d\t%d\t%d\t%d\t",m1,m2,m3,m4,m5,m6);
printf("\nAverage marks : %f",avg);
if(result=='p')
printf("\nResult :pass");
else
printf("\Result :fail");
printf("\Grade :%c",grade);
getch();
}
Labels:
C-Programming
Write a program to find out biggest number out of three numbers?
#include
#include
main()
{
int a,b,c;
printf("Enter any three numbers:");
scanf("%d%d%d", &a,&b,&c);
if((a>b) && (a>c))
printf ("The big number : %d", a);
else if(b>c)
printf("The big number : %d", b);
else
printf("The big number : %d", c);
getch();
}
#include
main()
{
int a,b,c;
printf("Enter any three numbers:");
scanf("%d%d%d", &a,&b,&c);
if((a>b) && (a>c))
printf ("The big number : %d", a);
else if(b>c)
printf("The big number : %d", b);
else
printf("The big number : %d", c);
getch();
}
Labels:
C-Programming
Subscribe to:
Posts (Atom)