sábado, 30 de abril de 2011

Programa que calcula fatorial feito com while, do while e for.

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

int main()
{

    int fat,i=1,tfat=1;
   
    printf("informe o fatorial = \n");
    scanf("%d",&fat);

USANDO O "WHILE"

    if( (fat==1)||(fat==0) )
        printf("fatorial = 1");

    else{

       while(i<=fat)
       {
           tfat *= i;
           i++;
       }

    printf("fatorial de %d %c = %d",fat,130,tfat);
    }

    getch();
    return(0);


/*  USANDO O "DO WHILE"

    if( (fat==1)||(fat==0) ){
          printf("fatorial = 1");}

    else{

         do{
            tfat *= i;
            i++;
              }
        while(i<=fat);

    printf("fatorial de %d %c = %d",fat,130,tfat);
    }

    getch();
    return(0);
                   */

 /*USANDO O "FOR"

        if( (fat==1)||(fat==0) ){
          printf("fatorial = 1");
          }

        else{
          for(i=1 ; i<=fat ; i++)
          tfat *= i;
          printf("fatorial de %d %c = %d",fat,130,tfat);
          }

    getch();
    return(0);
     */
   
}


//para fatoriais acima de 40 utilize double para tfat, para chamar a variavel utilize %.0lf


by  Wellington

Programa do Algoritmo de Melhor Aluno

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>                                                      //string.h é para poder usar
                                                                                    //as funções de string
int main()
{
    char nome[40];
    char melhor[40];
    int cont, quant;      
    float nota, max;
    max=0;
    cont=0;
   
    printf("Informe a quantidade de alunos: \n");
    scanf("%d",&quant);

    do{
          printf("informe o nome do aluno: \n");
          fflush(stdin);                                              //fflush limpa o buffer de teclado
          gets(nome);                                               //gets lê strings sem quebrar nos
                                                                            //espaços
       do{                                                             
          printf("informe a nota do aluno: \n");
          scanf("%f",&nota);
       }while((nota<0)||(nota>100));

       if(nota>max){
                    max = nota;
                    strcpy(melhor,nome);            //strcpy é a função para copiar strings,                                     
                    }                                            // a 1ª é para onde será copiada a 2ª.
       cont++;
    }while(cont<quant);

    printf("melhor aluno = %s\n",melhor);
    printf("melhor nota = %.2f",max);
   
    getch();
    return(0);
  
}


   
      by  Wellington
    

sexta-feira, 29 de abril de 2011

INICIO DO BLOG SIDUVIDA

BLOG CRIADO COM INTUITO DE FORMAR GRUPO DE ESTUDOS

CURSO SISTEMAS DE INFORMAÇÃO

AO DECORRER DO CURSO,

MATÉRIA RELACIONADA AOS ESTUDOS EM SALA DE AULA SERÁ POSTADO

DÚVIDAS, SUGESTÕES E ETC...

BONS ESTUDOS E BOA SORTE !!!