WAP to find the sum of the reciprocal of a set of integer numbers to be feed from the keyboard . however reciprocal of 0 is not defined and should be ignored...


void main()
{
float i,no,rev,sum;
clrscr();
for(i=1; i<=5;i++)
{
printf("Enter the number");
scanf("%f", &no);
if(no==0)
continue;
else
rev=1/no;
printf("\n%f",rev);
sum=sum+rev;
}
printf("\n\nsum of reciprocal=%f",sum);
getch();
}

WAP to read the age of 10 persons and count the number of person in the age group 50-60 (Use For and Continue Statement)


void main()
{
int i,age,c=0;
clrscr();
for(i=1; i<=10; i++)
{
printf("Enter the age of the person");
scanf("%d", &age);
if(age>50 && age<60)
{
c++;
continue;
}
}

printf("  %d",c);
getch();
}

WAP to evaluate sqyare root of a series of a numbers and print the result. if number is negative, program should print a message and keeps on counting number of negative values entered by the user......


#include<math.h>
void main()
{
int no,i,c=0,d;
clrscr();
for(i=1; i<=4; i++)
{
printf("Enter the number");
scanf("%d", &no);
if(no<0)
{
  printf("\nNo. is negative");
c++;
continue;
}
else
{
d=sqrt(no);
  printf("\nsqroot=%d", d);
}
printf("\nNegative numbers= %d",c);
}
getch();
}

WAP in which a loop is initialized by 1 and stops at 100. it will continue the loop when variable of loop is.....


  1. Less then or equal to 10
  2. less then 10
  3. equal to 10
  4. greater then 10
  5. greater then or equal to 10
    what did you observe????



void main()
{
int i;
clrscr();
for(i=1; i<=100; i++);
{
if(i<=100)
{
continue;
printf("%d",i);
}
}
getch();
}

WAP to read a value a and Calculate value of X for the Given Condition

// conditions are
 // if(a>4) then x=a+8
//  else x=a+5

void main()
{
int a,x;
clrscr();
printf("Enter the value of a");
scanf("%d",&a);
x=(a>4)? a+8:a+5;
printf(" %d",x);
getch();
}

WAP that determines whether someone is legally an adult (age>=21), but not a senior citizen (age>=65)


void main()
{
int age;
clrscr();
printf("Enter the age");
scanf("%d", &age);
(age>=21 && age<=65)?
printf("\n\nThe person is adult"):printf("\n\nThe person is not adult"):printf("\n\nThe person is not a senior citizen");
getch();
}

Given a point (x,y) WAP to find out it lies on the x-axis, y-axis or at the origin(0,0)

See Othere question This will give in another question or section

WAP by using conditional operator to determine whether a year entered through the keyboard is a leap century year or not


void main()
{
int year;
clrscr();
printf("Enter any year");
scanf("%d", &year);
(year%4==0)?
printf("\n\nIt is a leap year"):printf("\n\nIt is not a leap year");
getch();
}

WAP to check Whether a character entered through the keyboard is a special symbol or not


void main()
{
char no;
clrscr();
printf("Enter the number");
scanf("%c", &no);
(no>=0 && no<=47 || no>=58 && no<=64 || no>=91 && no<=96 || no>=123 && no<=255)?
printf("\n\nIt is a special symbol"):printf("\n\nIt is not a special symbol");
getch();
}

WAP to check whether the character entered through the keyboard is a lower case alphabet or not


void main()
{
char no;
clrscr();
printf("Enter the number");
scanf("%c", &no);
(no>=97 && no<=122)?
printf("\n\nIt is a lower case alphabet"):printf("\n\nIt is not a lower case alphabet");
getch();
}

WAP to check whether a given number is prime or not


void main()
{
int no,i;
clrscr();
printf("Enter the no");
scanf("%d",&no);
for(i=2; i<=no; i++)
{
if(no%i==0)
break;
}
if(no==i)
{
printf("prime");
}
else
{
printf("not prime");
}
getch();
}

WAP To Print prime numbers between 1 to 100


void main()
{
int i,j;
clrscr();

for(i=1; i<=100; i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
if(i==j)
printf("%d ",i);

}
getch();
}

WAP To Break A Loop At 10th Position When It is executed From 1 to 15


void main()
{
int i;
clrscr();
for(i=1; i<=15; i++)
{
if(i==10)
break;
printf("%d",i);
}
getch();
}

WAP To Calculate a power b by using pow() function


#include<math.h>
void main()
{
int a,b,power;
clrscr();
printf("Enter the value of a and b");
scanf("%d%d",&a,&b);
power=pow(a,b);
printf("%d",power);
getch();
}

WAP to exit from program. through exit(0) function


#include<math.h>
void main()
{
int a,b;
clrscr();
if (a>b)
printf("a is greater");
else
exit(0);
getch();
}

WAP to calculate random value for given number


#include<stdlib.h>
void main()
{
int a;
clrscr();
randomize();
printf("%d",random(50));
getch();
}

WAP to calculate Square root of a given number


#include<math.h>
void main()
{
int a,d;
clrscr();
printf("Enter the value of a");
scanf("%d",&a);
d=sqrt(a);
printf("%d",d);
getch();
}

WAP to calculate cos,acos,sin,asin,tan,Exponential & Log value

#include<math.h>
void main()
{
double a,c,s,as,t,e,l;
clrscr();
printf("Enter the value of a");
scanf("%lf",&a);
c=sin(a*3.14/180);
printf(" \nlf",c);
s=cos(a*3.14/180);
printf("\n%lf",s);
as=asin(a);
printf("\n%lf",as);
t=tan(a);
printf("\n%lf",t);
e=exp(a);
printf("\n%lf",e);
l=log(a);
printf("\n%lf",l);
getch();
}

WAP to calculate absolute value of a given number



#include<math.h>

void main()

{

int a,d;

clrscr();

printf("Enter the value of a");

scanf("%d",&a);

d=abs(a);

printf("%d",a);

getch();

}

How To Find Greater Number Between two numbers In C


How To Find Greater Number Between two numbers

#include<stdio.h>

#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter two no");
scanf("%d%d",&a,&b);
if(a>b)
{
printf(" a is greater");
}
else
{
printf("b is greater");
}
getch();
}

How To Start Programming With C


when You Installed Turbo C and C++ after that you want to know how to start programming

Here I will tell you that
Open DosBox That Is On Your Desktop(As A shortcut of DosBox)
when It open Click On "File" after that on "new"
now you seen a blue page
click on it
write the first is headerfils
header files are
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<graphics.h>
//etc..........
//after that you need to write any message but before that
//you need to write the main body so write
main()
{
//now you start your programme's body
//here you can write your msg
//for writing messege neet to put the command and the command is
//"printf" now see how can use this command
printf("My First C Programme");
getch();
}

now your programme is ready

see your fully programme that will show Your message"My First C Programme" is

#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<graphics.h>
main()
{
printf("My First C Programme");
getch();
}

and most importent is this before run this save with .c name
like that myfirst.c of no1.c or myprog.c
but always have .c exetensen

Any More Info Click Any Other post
any Help Comment here

How To Make A marquee In C




#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_STR_LEN 40

typedef enum { false = 0, true } bool;
typedef enum { LEFT, RIGHT, LEFT_CIRCULAR, RIGHT_CIRCULAR } Direction;

void marquee(char *, size_t count, Direction);
void delay(int);
void shift(char *, size_t distance, Direction);
bool isCircularShift(Direction);
bool isAllSpaces(const char *);

char msg[MAX_STR_LEN];
const size_t repeatCount = 2;
const int delayCount = 1e6;
const int shiftLen = 1;

int main(int argc, char *argv[]) {

    while (1) {
        printf("> ");
        fgets(msg,MAX_STR_LEN,stdin);
        *(strchr(msg,'\n')) = '\0';
        marquee(msg, repeatCount, LEFT_CIRCULAR);
        marquee(msg, repeatCount, RIGHT_CIRCULAR);
    }
    return 0;
}

void marquee(char *s0, size_t count, Direction dir) {
    size_t len = strlen(s0) * 3, i, j;
    char *s;

    if (len > 0) {
        s = calloc(len+1,sizeof(char));
        memset(s, ' ', len);
        memcpy(s, s0, strlen(s0));

        /* Scroll it. */
        for (i = 0; i < count; i++) {
            for (j = 0; j < len; j++) {
                printf("\r%s",s); fflush(stdout);
                shift(s, shiftLen, dir);
                delay(delayCount);
            }
        }

        /* Clear it. */
        dir = (dir == RIGHT_CIRCULAR) ? RIGHT : LEFT;
        while (isAllSpaces(s) == false) {
            shift(s, shiftLen, dir);
            printf("\r%s",s); fflush(stdout);
            delay(delayCount);
        }
        printf("\r"); fflush(stdout);
        free(s);
    }
}

void shift(char *a, size_t distance, Direction dir) {
    char *source, *dest, *bumpFrom, *rotateTo, temp;
    size_t n, aLen = strlen(a);

    if (distance > 0) {
        if ((dir == RIGHT) || (dir == RIGHT_CIRCULAR)) {
            source = a; dest = a+1;
            bumpFrom = &a[aLen-1]; rotateTo = &a[0];
        } else {
            source = a+1; dest = a;
            bumpFrom = &a[0]; rotateTo = &a[aLen-1];
        }
        for (n = 0; n < distance; n++) {
            temp = *bumpFrom;
            memmove(dest,source,aLen-1);
            if (isCircularShift(dir) == true) {
                *rotateTo = temp;
            } else {
                *rotateTo = ' ';
            }
        }
    }
}

bool isCircularShift(Direction dir) {
    return (dir == LEFT_CIRCULAR) || (dir == RIGHT_CIRCULAR);
}

bool isAllSpaces(const char *s) {
    bool allSpaces = true;
    const char *p = s;

    while ((*p != '\0') && (allSpaces == true)) {
        allSpaces = (*p++ == ' ');
    }
    return allSpaces;
}

double factorial(unsigned n) {
    if (n == 1) return n;
    return n * factorial(n-1);
}

void delay(int n) {
    int i;

    for (i = 0; i < n; i++) {
        factorial(10);
    }
}

How to find even and odd number in C




#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter two no");
scanf("%d%d",&a,&b);
if(a%2==0)
{
printf("no is even no");
}
else
{
printf("no is odd no");
}
getch();
}

Set Text Color And Backgroung Of Any programme In C




#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
{
textbackground(1);
textcolor(2);
cscanf("%d",&a);
if(a==1)
{
cprintf("sdf");
}
}
getch();
}

How to fine every type password thaty possiable by numeric values In C




#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f,g,h,i;
clrscr();
{
printf("Maybe passward are");
printf("\nminimam value");
scanf("%d",&a);
printf("\nMaxmim value");
scanf("%d",&b);
for(i=a;i<=b;i++)
{
for(h=a;h<=b;h++)
{
for(g=a;g<=b;g++)
{
for(f=a;f<=b;f++)
{
printf("\t%d%d%d%d",i,h,g,f);
}}}}}
getch();
}

How to find that given year is leap year or not in C




#include<stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("enter the year");
scanf("%d",&year);
if(year%4==0)
{
printf("year is leap year");
}
else
{
printf("year is not year");
}
getch();
}

A Short C Program and A simple program Of C


This is a very simple program. All it does is input two numbers from the keyboard and calculate their product. At this stage, don't worry about understanding the details of the program's workings. The point is to gain some familiarity with the parts of a C program so that you can better understand the listings presented later in this book.
Before looking at the sample program, you need to know what a function is, because functions are central to C programming. A function is an independent section of program code that performs a certain task and has been assigned a name. By referencing a function's name, your program can execute the code in the function. The program also can send information, called arguments, to the function, and the function can return information to the main part of the program. The two types of C functions are library functions, which are a part of the C compiler package, and user-defined functions, which you, the programmer, create.



1:  /* Program to calculate the product of two numbers. */
2:  #include <stdio.h>
3:
4:  int a,b,c;
5:
6:  int product(int x, int y);
7:
8:  main()
9:  {
10:     /* Input the first number */
11:     printf("Enter a number between 1 and 100: ");
12:     scanf("%d", &a);
13:
14:     /* Input the second number */
15:     printf("Enter another number between 1 and 100: ");
16:     scanf("%d", &b);
17:
18:     /* Calculate and display the product */
19:     c = product(a, b);
20:     printf ("%d times %d = %d\n", a, b, c);
21:
22:     return 0;
23: }
24:
25: /* Function returns the product of its two arguments */
26: int product(int x, int y)
27: {
28:     return (x * y);
29: }



Enter a number between 1 and 100: 35
Enter another number between 1 and 100: 23
35 times 23 = 805

Preparing to Program OF C


You should take certain steps when you're solving a problem. First, you must define the problem. If you don't know what the problem is, you can't find a solution! Once you know what the problem is, you can devise a plan to fix it. Once you have a plan, you can usually implement it. Once the plan is implemented, you must test the results to see whether the problem is solved. This same logic can be applied to many other areas, including programming.

When creating a program in C (or for that matter, a computer program in any language), you should follow a similar sequence of steps:
1. Determine the objective(s) of the program.
2. Determine the methods you want to use in writing the program.
3. Create the program to solve the problem.
4. Run the program to see the results.
An example of an objective (see step 1) might be to write a word processor or database program. A much simpler objective is to display your name on the screen. If you didn't have an objective, you wouldn't be writing a program, so you already have the first step done.
The second step is to determine the method you want to use to write the program. Do you need a computer program to solve the problem? What information needs to be tracked? What formulas will be used? During this step, you should try to determine what you need to know and in what order the solution should be implemented.
As an example, assume that someone asks you to write a program to determine the area inside a circle. Step 1 is complete, because you know your objective: determine the area inside a circle. Step 2 is to determine what you need to know to ascertain the area. In this example, assume that the user of the program will provide the radius of the circle. Knowing this, you can apply the formula pr2 to obtain the answer. Now you have the pieces you need, so you can continue to steps 3 and 4, which are called the Program Development Cycle.

Why Use C????


Why Use C?






In today's world of computer programming, there are many high-level languages to choose from, such as C, Pascal, BASIC, and Java. These are all excellent languages suited for most programming tasks. Even so, there are several reasons why many computer professionals feel that C is at the top of the list:









  • C is a powerful and flexible language. What you can accomplish with C is limited only by your imagination. The language itself places no constraints on you. C is used for projects as diverse as operating systems, word processors, graphics, spreadsheets, and even compilers for other languages.
  • C is a popular language preferred by professional programmers. As a result, a wide variety of C compilers and helpful accessories are available.
  • C is a portable language. Portable means that a C program written for one computer system (an IBM PC, for example) can be compiled and run on another system (a DEC VAX system, perhaps) with little or no modification. Portability is enhanced by the ANSI standard for C, the set of rules for C compilers.
  • C is a language of few words, containing only a handful of terms, called keywords, which serve as the base on which the language's functionality is built. You might think that a language with more keywords (sometimes called reserved words) would be more powerful. This isn't true. As you program with C, you will find that it can be programmed to do any task.
  • C is modular. C code can (and should) be written in routines called functions. These functions can be reused in other applications or programs. By passing pieces of information to the functions, you can create useful, reusable code.


As these features show, C is an excellent choice for your first programming language. What about C++? You might have heard about C++ and the programming technique called object-oriented programming. Perhaps you're wondering what the differences are between C and C++ and whether you should be teaching yourself C++ instead of C.
Not to worry! C++ is a superset of C, which means that C++ contains everything C does, plus new additions for object-oriented programming. If you do go on to learn C++, almost everything you learn about C will still apply to the C++ superset. In learning C, you are not only learning one of today's most powerful and popular programming languages, but you are also preparing yourself for object-oriented programming.
Another language that has gotten lots of attention is Java. Java, like C++, is based on C. If later you decide to learn Java, you will find that almost everything you learned about C can be applied.

A Brief History of the C Language


You might be wondering about the origin of the C language and where it got its name.
C was created by Dennis Ritchie at the Bell Telephone Laboratories in 1972.
The language wasn't created for the fun of it, but for a specific purpose: to design the
 UNIX operating system (which is used on many computers). From the beginning,
C was intended to be useful--to allow busy programmers to get things done.

Because C is such a powerful and flexible language, its use quickly spread beyond
 Bell Labs. Programmers everywhere began using it to write all sorts of programs.
Soon, however, different organizations began utilizing their own versions of C, and
subtle differences between implementations started to cause programmers headaches.
 In response to this problem, the American National Standards Institute (ANSI) formed
 a committee in 1983 to establish a standard definition of C, which became known as
ANSI Standard C. With few exceptions, every modern C compiler has the ability to
adhere to this standard.



Now, what about the name? The C language is so named because its
 predecessor was called B. The B language was developed by Ken Thompson of Bell Labs.
 You should be able to guess why it was called B.

Why Use C?

In today's world of computer programming, there are many high-level languages to choose from, such as C, Pascal, BASIC, and Java. These are all excellent languages suited for most programming tasks. Even so, there are several reasons why many computer professionals feel that C is at the top of the list:
  • C is a powerful and flexible language. What you can accomplish with C is limited only by your imagination. The language itself places no constraints on you. C is used for projects as diverse as operating systems, word processors, graphics, spreadsheets, and even compilers for other languages.
  • C is a popular language preferred by professional programmers. As a result, a wide variety of C compilers and helpful accessories are available.
  • C is a portable language. Portable means that a C program written for one computer system (an IBM PC, for example) can be compiled and run on another system (a DEC VAX system, perhaps) with little or no modification. Portability is enhanced by the ANSI standard for C, the set of rules for C compilers.
  • C is a language of few words, containing only a handful of terms, called keywords, which serve as the base on which the language's functionality is built. You might think that a language with more keywords (sometimes called reserved words) would be more powerful. This isn't true. As you program with C, you will find that it can be programmed to do any task.
  • C is modular. C code can (and should) be written in routines called functions. These functions can be reused in other applications or programs. By passing pieces of information to the functions, you can create useful, reusable code.


As these features show, C is an excellent choice for your first programming language. What about C++? You might have heard about C++ and the programming technique called object-oriented programming. Perhaps you're wondering what the differences are between C and C++ and whether you should be teaching yourself C++ instead of C.
Not to worry! C++ is a superset of C, which means that C++ contains everything C does, plus new additions for object-oriented programming. If you do go on to learn C++, almost everything you learn about C will still apply to the C++ superset. In learning C, you are not only learning one of today's most powerful and popular programming languages, but you are also preparing yourself for object-oriented programming.
Another language that has gotten lots of attention is Java. Java, like C++, is based on C. If later you decide to learn Java, you will find that almost everything you learned about C can be applied.

WEL_COME to C Universe


Hey Dear Welcome To C World
Here we made this blog to improve your knowledge about
 C Programming and help to improve your
computer programming knowledge.......................

Here we are specially going to help our those friends who
have troubles in programming.............................

In this blog we started with basic Knowledge to Upgredetion so
that you can learn Programming very easily..............................



                                 -- SUNIL KUMAR MUKESH KUMAR