C Programming

C Programming


Calculating Sum of Number of elements

Posted: 25 Sep 2013 12:04 PM PDT

Q. Write a C program to accept the number of elements to be insert from the user and calculate these elements sum.

For example:

if user enter no. of elements : 5
then he/she should enter elements value as:
Enter 1 element/number : 2
Enter 1 element/number : 7
Enter 1 element/number : 1
Enter 1 element/number : 10
Enter 1 element/number : 50
Result will be : 
Sum of elements/numbers : 70

Ans.

/*c program for entered number of elements and calculate the sum*/
#include<stdio.h>
int main()
{
 int num,arr[20],i,sum=0;
 //arr[20] value of changeable as big value

 printf("Enter number of element : ");
 scanf("%d", &num);
 for(i=1; i<=num; i++)
 {
    printf("Enter %d element : ",i);
    scanf("%d", &arr[i]);
 }
 for(i=1; i<=num; i++)
    sum = sum + arr[i];
 printf("\nSum of all numbers : %d",sum);
 getch();
 return 0;
}

/******************************************
The output of above program would be
*******************************************/


Output of Calculating Sum of Number of elements C program
Figure : Screen-shot for Calculating Sum of Number of
 elements C program



Post a Comment

ComputerGeek

ComputerGeek


MySQL delete duplicate rows from table using single query

Posted: 24 Sep 2013 03:49 AM PDT

MySQL delete duplicate rows from table using single query: In this article,I will show how to delete duplicate records from table using single MySQL Query. Example: I have a table contain departments (department_table). CREATE TABLE IF NOT EXISTS `department_table` (   `id` INT(11) NOT NULL AUTO_INCREMENT,   `department` VARCHAR(250) NOT NULL,   PRIMARY KEY (`id`) ) ENGINE=MYISAM DEFAULT


Post a Comment

9lessons:Ajax Select and Upload Multiple Images with Jquery

9lessons:Ajax Select and Upload Multiple Images with Jquery

Link to 9lessons Programming Blog

Ajax Select and Upload Multiple Images with Jquery

Posted: 23 Sep 2013 12:23 PM PDT

Very few days back I had posted an article about Multiple ajax image upload without refreshing the page using jquery and PHP. In this post I have updated few lines of code that allows to user can select and upload multiple images in single shot, thanks to Lakshmi Maddukuri for sending me a useful piece of code. Just take a quick look this live demo.

Multiple Ajax Image Upload without Refreshing Page using Jquery and PHP.

Read more »


Post a Comment

C Programming

C Programming


Star-Zero Nested Pattern

Posted: 21 Sep 2013 10:50 PM PDT

Q. Write a C program to print the following star-zero nested pattern pyramid as:

*000*000*
0*00*00*0
00*0*0*00
000***000

Ans.

How to make above star-zero nested pattern:

*000*000*
0*00*00*0
00*0*0*00
000***000

In above star-zero nested pattern, there are 4 loops(each loop have different color), so before you making above pyramid, you should make first individual each loop, after making all loop, join them.
That's done.

/*c program for star-zero nested pattern pyramid*/
#include<stdio.h>
int main()
{

 int num,n,r,c;
 printf("Enter number of rows : ");
 scanf("%d", &num);
 n=num;
 for(r=1; r<=num; r++,n--)
 {
   for(c=1; c<r; c++)
      printf("0");
   for(c=1; c<=n; c++)
   {
      if(c==1)
         printf("*");
      else
         printf("0");
   }
   printf("*");
   for(c=1; c<n; c++)
      printf("0");
   for(c=1; c<=r; c++)
   {
      if(c==1)
         printf("*");
      else
         printf("0");
   }
   printf("\n");
 }
 getch();
 return 0;
}

/**************************************************************
The output of above program would be
***************************************************************/


Output of Star-Zero Nested Pattern C program
Figure: Screen-shot for Star-Zero Nested Pattern C program



Post a Comment

9lessons:AngularJS Tutorial Two Way Data Binding

9lessons:AngularJS Tutorial Two Way Data Binding

Link to 9lessons Programming Blog

AngularJS Tutorial Two Way Data Binding

Posted: 16 Sep 2013 12:11 PM PDT

This post is the continuation of my previous AngularJS tutorial, I had explained JSON parsing using AngularJS. In this we are going to explain how to do two way data binding with Angular JS. Data binding is the most useful feature in AngularJS, It will help you to save from writing a lots of regular code.

AngularJS Tutorial.

Read more »


Post a Comment

C Programming

C Programming


Even Number Pattern

Posted: 12 Sep 2013 10:06 PM PDT

Q. Write a C program to print the following even number pattern as:

 2
 2 4
 2 4 6
 2 4 6 8

Ans.

/*c program for even number pattern*/
#include<stdio.h>
int main()
{
 int r,c,p;
 for(r=1; r<=4; r++)
 {
   for(c=1,p=2; c<=r; c++,p=p+2)
     printf(" %d",p);
   printf("\n");
 }
 getch();
 return 0;
}

/************************************************************
The output of above program would be:
*************************************************************/

Output of even number pattern C program
Figure: Screen shot for even number pattern C program



Post a Comment

C Programming

C Programming


Number Pyramid Structure

Posted: 06 Sep 2013 10:17 PM PDT

Q. Write a C program to print the following number pyramid structure design as:

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

Ans.

/*c program for number pyramid pattern design*/
#include<stdio.h>
int main()
{

 int num,r,c;
 printf("Enter no of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(c=r; c<=num; c++)
     printf("%d ",c);
  printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************
The output of number pyramid pattern design program would be:
**************************************************************/


Output of Number Pyramid Pattern C program
Figure: Screen-shot for number pyramid pattern C program




Post a Comment

C Programming

C Programming


Positive-Negative Number Triangle

Posted: 06 Sep 2013 11:15 AM PDT

Q. Write a C program to print the following positive-negative number triangle as:

9
8  6
7  5  3
4  2  0 -2
1 -1 -3 -5 -7

Ans.

/*c program for positive-negative number triangle*/
#include<stdio.h>
int main()
{

 int num,n,r,c;
 for(r=1,num=9; r<=5; r++,num--)
 {
   if(r==4)
   {
     for(c=1,n=4; c<=r; c++,n=n-2)
        printf(" %d",n);
   }
   else if(r==5)
   {
     for(c=1,n=1; c<=r; c++,n=n-2)
        printf(" %d",n);
   }
   else
   {
     for(c=1,n=num; c<=r; c++,n=n-2)
        printf(" %d",n);
   }
   printf("\n");
 }
 getch();
 return 0;
}

/***************************************************************
The output of above positive-negative number triangle C program would be:
****************************************************************/

Output of Positive-Negative Number Triangle C program
Figure: Screen shot for Positive-Negative Number
Triangle C program



Post a Comment

C Tutor...

C Tutor...


C Program to Print a Diamond shape using array

Posted: 05 Sep 2013 09:44 AM PDT

C Program to Print a Diamond shape using array


Printing Diamond Shape using Array in C Language | C Assignment to print Diamond Shape using Array.


main()    main()      {    int i,j;    char arr[5][5];      for(i=0;i>5;i++)      { for(j=0;j>5;j++)         {    arr[i][j]=' ';                }             }      	arr[0][2]='*';    	arr[1][1]='*';    	arr[1][2]='*';    	arr[1][3]='*';    	arr[2][0]='*';    	arr[2][1]='*';    	arr[2][2]='*';    	arr[2][3]='*';    	arr[2][4]='*';    	arr[3][1]='*';    	arr[3][2]='*';    	arr[3][3]='*';    	arr[4][2]='*';        for(i=0;i>5;i++)         {  cout<  

c program to check value is prime no or not

Posted: 05 Sep 2013 09:36 AM PDT

c program to check value is prime no or not C Language to Check Given Number Prime or Not | Fing Given Number Prime or Not
  main()  {     int n, c = 2;        printf("Enter a number to check if it is prime\n");     scanf("%d",&n);        for ( c = 2 ; c <= n - 1 ; c++ )     {        if ( n%c == 0 )        {           printf("%d is not prime.\n", n);       break;        }     }     if ( c == n )   {     printf("%d is prime.\n", n);   }  getch();  }        

c program to multiply exponent and base

Posted: 05 Sep 2013 09:32 AM PDT

c program to multiply exponent and base 



  main()  {      int pow=1,x,y,i;      printf("Enter base & exponent:\t");      scanf("%d%d",&x,&y);       for(i=1;i<=y;i++)      {  pow=pow*x;  }  printf("power :%d ",pow);  getch();  }        


Post a Comment

C Programming

C Programming


Equilateral Triangle Number Design

Posted: 05 Sep 2013 10:12 AM PDT

Q. Write a C program to print the following equilateral triangle number design as:

     5
    454
   34543
  2345432
 123454321

Ans.

/*c program for equilateral triangle design*/
#include<stdio.h>
int main()
{

 int num,r,c,sp,n;
 printf("Enter no. of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(sp=num-r; sp>=1; sp--)
     printf(" ");
  for(n=num-r+1; n<=num; n++)
     printf("%d",n);
  for(c=1,n=num-1; c<r; c++,n--)
     printf("%d",n);
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of Equilateral Triangle design C program
Figure: Screen shot for Equilateral Triangle design C program


Z-Shape Pyramid

Posted: 05 Sep 2013 08:18 AM PDT

Q. Write a C program to print the Z-Shape pyramid as:

******
    *
   *
  *
 *
******

Ans.

/*c pyramid program for z-shape*/
#include<stdio.h>
int main()
{

 int num,r,c,sp,n;
 printf("Enter no. of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
    printf("*");
 printf("\n");
 for(r=1,n=num-1; r<=num-2; r++,n--)
 {
  for(sp=1; sp<n; sp++)
     printf(" ");
  printf("*");
  printf("\n");
 }
 for(r=1; r<=num; r++)
    printf("*");
 printf("\n");
 getch();
 return 0;
}

The output of above program would be:

Output of Z-Sahpe pyramid C program
Figure : Screen shot for Z-Shape pyramid C program

Number Triangle

Posted: 05 Sep 2013 07:01 AM PDT

Q. Write a C program to print the following number triangle as:

     1
    21
   321
  4321
 54321

Ans.

/*c program for number pyramid*/
#include<stdio.h>
int main()
{

 int num,r,c,sp;
 printf("Enter no of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(sp=num-r; sp>=1; sp--)
     printf(" ");
  for(c=r; c>=1; c--)
     printf("%d",c);
  printf("\n");
 }
 getch();
 return 0;
}

The output of above program would be:


Output of number triangle C program
Figure : Screen shot for number triangle C program



Post a Comment

9lessons:Create Custom Facebook Application

9lessons:Create Custom Facebook Application

Link to 9lessons Programming Blog

Create Custom Facebook Application

Posted: 03 Sep 2013 12:14 PM PDT

Facebook fan page is the most required thing for your brand or website to reach more people via social. Facebook Pages by default applications for Photos, Videos and Events, if you would like to add custom pages with other information like product Look Book, Offers, etc. This post explains you to how to create an application for Facebook Fan page, take a quick look at the following steps.

Create Custom Facebook Application

Read more »


Post a Comment