Click here to download:
https://docs.google.com/file/d/0BxNYvl5CVSfXOTA0dFltalVZZE0/edit?usp=sharing&pli=1
1. Clik the link
2. Go to File
3.Click Download
4. after complete open the Word file and Edit Your Enrollment Number and Name.
Tnou Study Center
Blog Owner: Vignesh A
Search This Blog
Wednesday, February 27, 2013
Sunday, February 24, 2013
TNOU BCA PRACTICAL C, C++
c program - print integers:
#include <stdio.h> int main() { int a; printf("Enter an integer\n"); scanf("%d", &a); printf("Integer that you have entered is %d\n", a); return 0; }
_______________________________________________________________________________
To add two numbers:
#include<stdio.h> int main() { int a, b, c; printf("Enter two numbers to add\n"); scanf("%d%d",&a,&b); c = a + b; printf("Sum of entered numbers = %d\n",c); return 0; }
_______________________________________________________________________________
To check odd or even:
#include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( n%2 == 0 ) printf("Even\n"); else printf("Odd\n"); return 0; }
________________________________________________________________________________
basic arithmetic operations which are addition, subtraction,
multiplication and division of two numbers. Numbers are assumed to be
integers and will be entered by the user:
#include <stdio.h> int main() { int first, second, add, subtract, multiply; float divide; printf("Enter two integers\n"); scanf("%d%d", &first, &second); add = first + second; subtract = first - second; multiply = first * second; divide = first / (float)second; //typecasting printf("Sum = %d\n",add); printf("Difference = %d\n",subtract); printf("Multiplication = %d\n",multiply); printf("Division = %.2f\n",divide); return 0; }
_________________________________________________________________________________
C program to convert decimal to binary:
#include <stdio.h> int main() { int n, c, k; printf("Enter an integer in decimal number system\n"); scanf("%d", &n); printf("%d in binary number system is:\n", n); for (c = 31; c >= 0; c--) { k = n >> c; if (k & 1) printf("1"); else printf("0"); } printf("\n"); return 0; }
__________________________________________________________________________________
Palindrome number in c :
#include <stdio.h> int main() { int n, reverse = 0, temp; printf("Enter a number to check if it is a palindrome or not\n"); scanf("%d",&n); temp = n; while( temp != 0 ) { reverse = reverse * 10; reverse = reverse + temp%10; temp = temp/10; } if ( n == reverse ) printf("%d is a palindrome number.\n", n); else printf("%d is not a palindrome number.\n", n); return 0; }
_______________________________________________________________________________
C program to find hcf and lcm:
#include <stdio.h> int main() { int a, b, x, y, t, gcd, lcm; printf("Enter two integers\n"); scanf("%d%d", &x, &y); a = x; b = y; while (b != 0) { t = b; b = a % b; a = t; } gcd = a; lcm = (x*y)/gcd; printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd); printf("Least common multiple of %d and %d = %d\n", x, y, lcm); return 0; }
_________________________________________________________________________________
Friday, February 15, 2013
Subscribe to:
Posts (Atom)