dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Programming in C

  1. #1
    Join Date
    Mar 2017
    Posts
    3

    Programming in C

    Hello Everybody can you help me with this exercise please i will have to give it back on thursday and i don't understand it can we do it together please i have a lot of other homework to give back and i'm too late on it
    sorry for my english i am a french native .


    EXERCISE 1: Write a program that asks the user to enter a series of 10
    integer Values, the program determines and displays the biggest and smallest of the
    serie.
    EXERCISE 2: Write a program that asks the user to enter a series of n
    integer Values, the program determines and displays the biggest and smallest of the
    serie.
    EXERCISE 3: Write a program that asks the user to enter a series of n integer
    Values, the program determines and displays the average of the values ​​in the serie.
    EXERCISE 4: Write a program that asks the user to enter a series of n integer
    Values, the program determines and displays the number of positive values ​​and the
    Number of negative values ​​of the series.
    EXERCISE 5: Write a program that asks the user to enter an integer value
    The program determines and displays the average of values ​​between 1 and
    Value entered.
    EXERCISE 6: Write a program that instructs the user to enter an integer value
    Positive, the program determines and displays the average of the even numbers between 1 and
    The entered value.
    EXERCISE 7: Write a program that asks the user to enter an integer value
    Positive, the program determines and displays whether the number is a prime number or not. A
    Prime number must have only 2 divisors which are 1 and itself.
    EXERCISE 8: Write a program that asks the user to enter an integer value
    Positive, the program determines and displays whether the number is a perfect number or not. A
    Number is perfect if the sum of these divisors except itself is equal to this number.
    EXERCISE 9: Write a program that instructs the user to enter an integer value
    The program determines and displays all prime numbers between 1 and
    Input value.
    EXERCISE 10: Write a program that instructs the user to enter an integer value
    Positive, the program determines and displays all perfect numbers between 1 and
    Value entered.
    EXERCISE 11: Write a program that asks the user to enter an integer value
    Positive (n), the program determines and displays the first n prime numbers.
    EXERCISE 12: Write a program that asks the user to enter an integer value
    Positive (n), the program determines and displays the first n perfect numbers.
    EXERCISE 1 3: Write a program that asks the user to enter a series of N
    Products, the program displays all the data for each product and its value in
    stock. A product is characterized by its code (integer), its reference (chain), its price
    (Real) and its quantity in stock (real).
    EXERCISE 14: Write a program that instructs the user to enter an integer value
    Positive (n), the program determines and displays the multiplication tables of the numbers
    Between 1 and n.

  2. #2
    Join Date
    Jan 2017
    Posts
    8
    Please write did you find answers for these tasks?

  3. #3
    Join Date
    Mar 2017
    Posts
    3
    I try to do the 6 of them but the rest i can't do it . So i'm going to post them and please read it to try to find errors. Actually when I run it, they work except exercise 6. So can you check it for me cause my professor told us that it may works but that doesn't mean your code is correct.... So can you help me please ... Here the 6 exercises i've done

    Exercise 1


    #include<stdio.h>
    int main()
    {
    int i, n, max,min;

    printf ("Saisir la premiere valeur entiere. \n");
    scanf ("%d", &n);
    max = n;
    min=n;

    for (i=0; i<9 ; i++)
    {
    printf ("\n Entrer une autre valeur entiere. \n");
    scanf ("%d",&n);
    if (n>max)
    max=n;
    if (n<min)
    min=n;
    }
    printf (" Le plus grand nombre de la serie est : %d", max);
    printf (" Le plus petit nombre de la serie est %d", min);

    }

    Exercise 2


    #include<stdio.h>
    main()
    {
    int i, n, max,min, nb;
    printf ("Entrer le nombre de valeurs que vous voulez saisir. \n");
    scanf ("%d", &nb);
    printf ("Saisir la premiere valeur entiere \n");
    scanf ("%d", &n);
    max = n;
    min =n;
    for (i=1; i<=nb -1 ; i++)
    {
    printf (" Entrer une autre valeur entiere. \n");
    scanf ("%d",&n);
    if (n>max)
    max=n;
    if (n<min)
    min=n;
    }
    printf (" Le plus grand nombre de la serie est : %d", max);
    printf (" Le plus petit nombre de la serie est %d", min);
    }





    Exercise 3

    #include <stdio.h>
    main()
    {
    int n,s,nb_val,i;
    float moy ;
    i=0;
    s=0;
    printf("Entrer le nombre de valeurs que vous voulez saisir. \n");
    scanf("%d", &nb_val);
    do{


    printf(" Entrer une autre valeur entiere. \n");
    scanf ("%d",&n);
    s=s+n;
    i++;
    }while (i<nb_val);
    moy = (float)s/nb_val;
    printf(" La moyenne des valeurs de la serie = %f", moy);
    }



    Exercise 4


    #include<stdio.h>
    main()
    {
    int n,i,cpt,s,nb_paire;
    float moy;
    printf("Entrer une valeur entiere positive \n");
    scanf("%d",&n);
    s=0; cpt=0;
    for(i=1;i<=n;i++)
    {
    if((i%2)==0)
    {
    s=s+n;
    cpt++;
    }
    }
    moy= (float)s/cpt;
    printf("\n la moyenne est %f \n",moy);
    }



    Exercise 5

    #include<stdio.h>
    main()
    {
    int n,i,cpt,s;
    float moy;
    printf("Entrer une valeur entiere positive \n");
    scanf("%d",&n);
    s=0; cpt=0;
    for(i=1;i<=n;i++)
    {
    s=s+i;
    cpt++;
    moy= (float)s/cpt;
    }

    printf("\n la moyenne est %f \n",moy);
    }

    Exercise 6

    #include<stdio.h>
    main()
    {
    int n,i,cpt,s,nb_paire;
    float moy;
    printf("Entrer une valeur entiere positive \n");
    scanf("%d",&n);
    s=0; cpt=0;
    for(i=1;i<=n;i++)
    {
    if((i%2)==0)
    {
    s=s+n;
    cpt++;
    }
    }
    moy= (float)s/cpt;
    printf("\n la moyenne est %f \n",moy);
    }

  4. #4
    Join Date
    Mar 2017
    Posts
    14
    These programs are very basic and I suggest that you should try to solve it on your own. It is good for you only. If we write code for you then you will learn nothing from the assignment you got.

  5. #5
    Join Date
    Mar 2017
    Posts
    3
    Quote Originally Posted by crishwatson View Post
    These programs are very basic and I suggest that you should try to solve it on your own. It is good for you only. If we write code for you then you will learn nothing from the assignment you got.
    oh no you got it all wrong I'm just asking you guys to check my code if the way i writed is correct

  6. #6
    Join Date
    Mar 2017
    Posts
    14
    The last one seems fine to me. I didn't find any error in the code. However, it is required to run it practically to see if there is any warning or error. Syntactically, it is correct, logically it is correct.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles